nooku is a Public Portfolio from Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

Create your own Portfolio or check out other free and subscription products from Assembla that will help accelerate your development projects.

nooku-components

Commit 1041

User picture
  • Author: johanjanssens
  • 2011-10-09 00:04 (over 2 years ago)

Merged from /branches/development

Files Affected

 
10401041
32
$jversion   = JVersion::isCompatible('1.6.0') ? '1.6' : '1.5';
32
$jversion   = JVersion::isCompatible('1.6.0') ? '1.6' : '1.5';
33
 
33
 
34
//Run platform specific procedures
34
//Run platform specific procedures
35
require JPATH_ROOT.'/administrator/components/com_'.$package.'/install/install.'.$jversion.'.php';
35
require JPATH_ROOT.'/administrator/components/com_'.$package.'/install/uninstall.'.$jversion.'.php';
36
 
36
 
37
// Delete framework folders, like com_default, mod_default
37
// Delete framework folders, like com_default, mod_default
38
foreach ($manifest->framework->folder as $folder)
38
foreach ($manifest->framework->folder as $folder)
10401041
45
        <file>/plugins/system/koowa.php</file>
45
        <file>/plugins/system/koowa.php</file>
46
        <file>/plugins/system/koowa.xml</file>
46
        <file>/plugins/system/koowa.xml</file>
47
 
47
 
 
 
48
        <folder src="/media/com_default">/media/com_default</folder>
48
        <folder src="/site/components/com_default">/components/com_default</folder>
49
        <folder src="/site/components/com_default">/components/com_default</folder>
49
        <folder src="/site/modules/mod_default">/modules/mod_default</folder>
50
        <folder src="/site/modules/mod_default">/modules/mod_default</folder>
50
        <folder>/administrator/components/com_default</folder>
51
        <folder>/administrator/components/com_default</folder>
10401041
1
<?php
1
<?php
2
/** $Id$ */
2
/**
 
 
3
 * @version        $Id$
 
 
4
 * @category    Nooku
 
 
5
 * @package     Nooku_Components
 
 
6
 * @subpackage  Logs
 
 
7
 * @copyright    Copyright (C) 2010 Timble CVBA and Contributors. (http://www.timble.net)
 
 
8
 * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 
 
9
 * @link        http://www.nooku.org
 
 
10
 */
3
 
11
 
 
 
12
/**
 
 
13
 * Log Behavior
 
 
14
 *
 
 
15
 * @author      Israel Canasa <israel@timble.net>
 
 
16
 * @category    Nooku
 
 
17
 * @package        Nooku_Components
 
 
18
 * @subpackage     Logs
 
 
19
 */
 
 
20
 
4
class ComLogsControllerBehaviorLoggable extends KControllerBehaviorAbstract
21
class ComLogsControllerBehaviorLoggable extends KControllerBehaviorAbstract
5
{
22
{
6
    protected $_title_column = '';
 
 
7
    protected $_actions;
23
    protected $_actions;
8
 
24
    protected $_title_column;
 
 
25
 
9
    public function __construct(KConfig $config)
26
    public function __construct(KConfig $config)
10
    { 
27
    { 
11
        parent::__construct($config);
28
        parent::__construct($config);
12
 
29
 
 
 
30
        $this->_actions = $config->actions->toArray();
13
        $this->_title_column = $config->title_column;
31
        $this->_title_column = $config->title_column;
14
        
 
 
15
        $this->_actions = $config->actions->toArray();
 
 
16
        if (empty($this->_actions)) {
 
 
17
            $this->_actions = array('after.edit', 'after.add', 'after.delete');
 
 
18
        }
 
 
19
    }
32
    }
20
 
33
 
21
    protected function _initialize(KConfig $config)
34
    protected function _initialize(KConfig $config)
22
    {
35
    {
23
        $config->append(array(
36
        $config->append(array(
24
            'priority'   => KCommand::PRIORITY_LOW,
37
            'priority'   => KCommand::PRIORITY_LOWEST,
25
            'actions' => array(),
38
            'actions' => array('after.edit', 'after.add', 'after.delete'),
26
            'title_column' => 'title',
39
            'title_column' => 'title',
27
        ));
40
        ));
28
 
41
 
...
 
...
 
29
        parent::_initialize($config);
42
        parent::_initialize($config);
30
    }
43
    }
31
 
44
 
32
    public function execute($name, KCommandContext $context) 
45
    public function execute($name, KCommandContext $context)
33
    {
46
    {
34
        if(!in_array($name, $this->_actions))
47
        if(!in_array($name, $this->_actions))
35
            return;
48
            return;
36
        
49
 
37
        $identifier = $context->caller->getIdentifier();
50
        $identifier = $context->caller->getIdentifier();
38
 
51
                
39
        $data = array(
52
        $data = array(
40
            'action' => $context->action,
53
            'action' => $context->action,
41
            'application' => $identifier->application,
54
            'application' => $identifier->application,
...
 
...
 
47
        $rowset = array();
60
        $rowset = array();
48
        if ($context->result instanceof KDatabaseRowAbstract) {
61
        if ($context->result instanceof KDatabaseRowAbstract) {
49
            $rowset[] =  $context->result;
62
            $rowset[] =  $context->result;
50
        } else {
63
        } elseif($context->result instanceof KDatabaseRowsetAbstract) {
51
            $rowset = KConfig::toData($context->result);
64
            $rowset = $context->result;
 
 
65
        }else{
 
 
66
            return false;      
52
        }
67
        }
53
 
68
 
54
        foreach ($rowset as $row)
69
        foreach ($rowset as $row)
...
 
...
 
55
        {
70
        {
56
            //Only log if the row status is valid.
71
            //Only log if the row status is valid.
57
            $status = $row->getStatus();
72
            $status = $row->getStatus();
58
 
73
            
59
            if(!empty($status))
74
            if(!empty($status))
60
            {
75
            {
61
                if ($row->{$this->_title_column}) {
76
                if ($row->{$this->_title_column}) {
...
 
...
 
66
 
81
 
67
                $data['row_id'] = $row->id;
82
                $data['row_id'] = $row->id;
68
 
83
 
69
                KFactory::tmp('admin::com.logs.model.logs')
84
                $this->getService('com://admin/logs.model.logs')
70
                    ->getItem()
85
                    ->getItem()
71
                    ->setData($data)
86
                    ->setData($data)
72
                    ->save();
87
                    ->save();
73
            }
88
            }
74
        }
89
        }
75
        
 
 
76
        return true;
 
 
77
    }
90
    }
78
 
91
 
79
    public function getHandle()
92
    public function getHandle()
10401041
3
 
3
 
4
class ComLogsControllerLog extends ComDefaultControllerDefault
4
class ComLogsControllerLog extends ComDefaultControllerDefault
5
{
5
{
6
    public function __construct(KConfig $config)
6
 
7
    {
 
 
8
        parent::__construct($config);
 
 
9
        
 
 
10
        $this->_request->package = $config->package;
 
 
11
        
 
 
12
        if ($this->isDispatched() && $config->package) {
 
 
13
            $this->_request->layout = 'package_list';
 
 
14
            
 
 
15
            // Inherit the views from the calling component's view
 
 
16
            $view = clone $this->getView()->getIdentifier();
 
 
17
            $view->package = $config->package;
 
 
18
            
 
 
19
            $this->getView()->views = KFactory::get($view)->views;
 
 
20
        }
 
 
21
    }
 
 
22
    
 
 
23
    protected function _initialize(KConfig $config)
 
 
24
    {
 
 
25
        $config->append(array(
 
 
26
            'package' => null,
 
 
27
        ));
 
 
28
        
 
 
29
        parent::_initialize($config);
 
 
30
        
 
 
31
        $config->view = 'admin::com.logs.view.logs.html';
 
 
32
        $config->model = 'admin::com.logs.model.logs';
 
 
33
        $config->toolbar = 'admin::com.logs.controller.toolbar.logs';
 
 
34
    }
 
 
35
    
 
 
36
    public function loadState(KCommandContext $context)
 
 
37
    {
 
 
38
        // Built the session identifier based on the action
 
 
39
        $identifier  = $this->getModel()->getIdentifier().'.'.$context->action;
 
 
40
        $state       = KRequest::get('session.'.$identifier, 'raw', array());
 
 
41
        $state['id'] = null;
 
 
42
        
 
 
43
        //Append the data to the request object
 
 
44
        $this->_request->append($state);
 
 
45
        
 
 
46
        //Push the request in the model
 
 
47
        $this->getModel()->set($this->getRequest());
 
 
48
        
 
 
49
        return $this;
 
 
50
    }
 
 
51
}
7
}
10401041
1
<?php
1
<?php
 
 
2
/**
 
 
3
 * @version     $Id$
 
 
4
 * @category    Nooku
 
 
5
 * @package     Nooku_Components
 
 
6
 * @subpackage  Logs
 
 
7
 * @copyright   Copyright (C) 2010 Timble CVBA and Contributors. (http://www.timble.net)
 
 
8
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 
 
9
 * @link        http://www.nooku.org
 
 
10
 */
2
 
11
 
 
 
12
/**
 
 
13
 * Logs Toolbar
 
 
14
 *
 
 
15
 * @author      Israel Canasa <israel@timble.net>
 
 
16
 * @category    Nooku
 
 
17
 * @package     Nooku_Components
 
 
18
 * @subpackage  Logs
 
 
19
 */
3
class ComLogsControllerToolbarLogs extends ComDefaultControllerToolbarDefault
20
class ComLogsControllerToolbarLogs extends ComDefaultControllerToolbarDefault
4
{
21
{
5
    public function getCommands()
22
    public function getCommands()
6
    {
23
    {
7
        $this->reset()->addDelete();
24
        $this->reset()
8
 
25
             ->addDelete();
 
 
26
 
9
        return parent::getCommands();
27
        return parent::getCommands();
10
    }
28
    }
11
 
29
 
10401041
17
 * @package        Nooku_Components
17
 * @package        Nooku_Components
18
 * @subpackage     Logs
18
 * @subpackage     Logs
19
 */
19
 */
20
 
20
echo KService::get('com://admin/logs.dispatcher')->dispatch();
21
echo KFactory::get('admin::com.logs.dispatcher')->dispatch();
 
 
10401041
1
<?php
1
<?php
2
/** $Id$ */
2
/** $Id$ */
3
 
3
 
4
class ComLogsModelLogs extends KModelTable
4
class ComLogsModelLogs extends ComDefaultModelDefault
5
{
5
{
6
    protected $_column;
 
 
7
 
 
 
8
    public function __construct(KConfig $config)
6
    public function __construct(KConfig $config)
9
    {
7
    {
10
        parent::__construct($config);
8
        parent::__construct($config);
...
 
...
 
15
            ->insert('package', 'cmd')
13
            ->insert('package', 'cmd')
16
            ->insert('name', 'cmd')
14
            ->insert('name', 'cmd')
17
            ->insert('action', 'cmd')
15
            ->insert('action', 'cmd')
18
            ->insert('user', 'cmd');
16
            ->insert('user', 'cmd')
 
 
17
            ->insert('distinct', 'boolean', false)
 
 
18
            ->insert('column', 'cmd');
19
 
19
 
20
        $this->_state
20
        $this->_state->remove('direction')->insert('direction', 'word', 'desc');
21
            ->remove('sort')->insert('sort', 'cmd', 'created_on')
21
        // Force ordering by created_on
22
            ->remove('direction')->insert('direction', 'word', 'desc');
22
        $this->_state->sort = 'created_on';
23
    }
23
    }
24
 
24
 
25
    protected function _buildQueryColumns(KDatabaseQuery $query)
25
    protected function _buildQueryColumns(KDatabaseQuery $query)
26
    {
26
    {
27
        parent::_buildQueryColumns($query);
27
        if($this->_state->distinct && !empty($this->_state->column)) 
28
 
28
        {
29
        $query->select('users.name AS created_by_name');
29
            $query->distinct()
 
 
30
                ->select($this->_state->column)
 
 
31
                ->select($this->_state->column . ' AS logs_log_id');
 
 
32
        }
 
 
33
        else
 
 
34
        {
 
 
35
            parent::_buildQueryColumns($query);
 
 
36
            $query->select('users.name AS created_by_name');
 
 
37
        }
30
    }
38
    }
31
 
39
 
32
    protected function _buildQueryJoins(KDatabaseQuery $query)
40
    protected function _buildQueryJoins(KDatabaseQuery $query)
...
 
...
 
46
            $query->where('tbl.type', '=', $this->_state->type);
54
            $query->where('tbl.type', '=', $this->_state->type);
47
        }
55
        }
48
 
56
 
49
        if ($this->_state->package) {
57
        if ($this->_state->package && !($this->_state->distinct && !empty($this->_state->column))) {
50
            $query->where('tbl.package', '=', $this->_state->package);
58
            $query->where('tbl.package', '=', $this->_state->package);
51
        }
59
        }
52
 
60
 
...
 
...
 
62
            $query->where('tbl.created_by', '=', $this->_state->user);
70
            $query->where('tbl.created_by', '=', $this->_state->user);
63
        }
71
        }
64
    }
72
    }
 
 
73
 
 
 
74
    protected function _buildQueryOrder(KDatabaseQuery $query)
 
 
75
    {
 
 
76
        if($this->_state->distinct && !empty($this->_state->column)) 
 
 
77
        {
 
 
78
            $query->order('package', 'asc');
 
 
79
        }
 
 
80
        else parent::_buildQueryOrder($query);
 
 
81
 
 
 
82
    }
65
}
83
}
10401041
3
 
3
 
4
<style src="media://com_logs/css/logs-default.css" />
4
<style src="media://com_logs/css/logs-default.css" />
5
 
5
 
 
 
6
<!-- Start Sidebar -->
 
 
7
<div id="sidebar">
 
 
8
    <?=@template('packages')?>
 
 
9
</div>
 
 
10
<!-- End Sidebar -->
 
 
11
 
6
<div id="list" class="-koowa-box-flex">
12
<div id="list" class="-koowa-box-flex">
7
    <form action="<?= @route()?>" method="get" class="-koowa-box-flex">
13
 
 
 
14
    <!-- Start Filter -->
 
 
15
    <?=@template('filters')?>
 
 
16
    <!-- End Filter -->
 
 
17
 
 
 
18
    <!-- Start Logs List -->
 
 
19
    <form action="<?= @route()?>" method="get" class="-koowa-grid">
8
        <table class="adminlist" style="clear: both;">
20
        <table class="adminlist" style="clear: both;">
9
            <thead>
21
            <thead>
10
                <tr>
22
                <tr>
11
                    <th width="5">
23
                    <th style="text-align:left;width:10px">
12
                        <?= @helper('grid.checkall') ?>
24
                        <?= @helper('grid.checkall') ?>
13
                    </th>
25
                    </th>
14
                    <th>
26
                    <th class="-logs-when"><?=@text('When')?></th>
15
                        <?= @helper('grid.sort', array('title' => 'Applicaton', 'column' => 'application')) ?>
27
                    <th class="-logs-message"><?=@text('Log Message')?></th>
16
                    </th>
28
                    <th class="-logs-item"><?=@text('Related Item')?></th>
17
                    <th>
 
 
18
                        <?= @helper('grid.sort', array('title' => 'Type', 'column' => 'type')) ?>
 
 
19
                    </th>
 
 
20
                    <th>
 
 
21
                        <?= @helper('grid.sort', array('title' => 'Package', 'column' => 'package')) ?>
 
 
22
                    </th>
 
 
23
                    <th>
 
 
24
                        <?= @helper('grid.sort', array('title' => 'Name', 'column' => 'name')) ?>
 
 
25
                    </th>
 
 
26
                    <th>
 
 
27
                        <?= @helper('grid.sort', array('title' => 'Action', 'column' => 'action')) ?>
 
 
28
                    </th>
 
 
29
                    <th>
 
 
30
                        <?= @helper('grid.sort', array('title' => 'Created by', 'column' => 'created_by')) ?>
 
 
31
                    </th>
 
 
32
                    <th>
 
 
33
                        <?= @helper('grid.sort', array('title' => 'Created on', 'column' => 'created_on')) ?>
 
 
34
                    </th>
 
 
35
                </tr>
29
                </tr>
36
                <tr class="filters">
 
 
37
                    <td>
 
 
38
                        <?= @text('Filters') ?>    
 
 
39
                    </td>
 
 
40
                    <td>
 
 
41
                        <?= @helper('listbox.applications',  array('attribs' => array('onchange' => 'this.form.submit();'))) ?>
 
 
42
                    </td>
 
 
43
                    <td>
 
 
44
                        <?= @helper('listbox.types',  array('attribs' => array('onchange' => 'this.form.submit();'))) ?>
 
 
45
                    </td>
 
 
46
                    <td>
 
 
47
                        <?= @helper('listbox.packages',  array('attribs' => array('onchange' => 'this.form.submit();'))) ?>
 
 
48
                    </td>
 
 
49
                    <td>
 
 
50
                        <?= @helper('listbox.names',  array('attribs' => array('onchange' => 'this.form.submit();'))) ?>
 
 
51
                    </td>
 
 
52
                    <td>
 
 
53
                        <?= @helper('listbox.actions',  array('attribs' => array('onchange' => 'this.form.submit();'))) ?>
 
 
54
                    </td>
 
 
55
                    <td colspan="2">
 
 
56
                    </td>
 
 
57
                </tr>
 
 
58
            </thead>
30
            </thead>
59
 
31
 
60
            <tbody>
32
            <tbody>
...
 
...
 
62
                    <?= @template('default_logs'); ?>
34
                    <?= @template('default_logs'); ?>
63
                <? else : ?>
35
                <? else : ?>
64
                <tr>
36
                <tr>
65
                    <td colspan="8" align="center">
37
                    <td colspan="20" align="center">
66
                        <?= @text('No items found'); ?>
38
                        <?= @text('No items found'); ?>
67
                    </td>
39
                    </td>
68
                </tr>
40
                </tr>
...
 
...
 
78
            </tfoot>
50
            </tfoot>
79
        </table>
51
        </table>
80
    </form>
52
    </form>
 
 
53
    <!-- End Logs List -->
81
</div>
54
</div>
10401041
1
<? /** $Id$ */ ?>
1
<? /** $Id$ */ ?>
2
<? defined('KOOWA') or die('Restricted access'); ?>
2
<? defined('KOOWA') or die('Restricted access'); ?>
3
 
3
 
4
<? foreach ($logs as $log) : ?>
4
<?
5
<tr>
5
$timeago = '';
6
    <td align="center">
6
foreach ($logs as $log) : 
7
        <?= @helper('grid.checkbox',array('row' => $log)); ?>
7
    $timeago_text = @timeago($log->created_on);
8
    </td>
8
    $show_timeago = ($timeago != $timeago_text);
9
    <td>
9
    $timeago = $timeago_text;
10
        <?= $log->application ?>
10
 
11
    </td>
11
?>
12
    <td>
12
    <?php if ($show_timeago): ?>
13
        <?= $log->type ?>
13
        <tr>
14
    </td>
14
            <td class="-logs-timeago" colspan="4">
15
    <td>
15
                <?=($show_timeago) ? $timeago_text: ''?>
16
        <?= $log->package ?>
16
            </td>
17
    </td>
17
        </tr>
18
    <td>
18
    <?php endif ?>
19
        <?= $log->name ?>
19
 
20
    </td>
20
    <tr>
21
    <td>
21
        <td style="text-align:center">
22
        <?= $log->action ?>
22
            <?= @helper('grid.checkbox',array('row' => $log)); ?>
23
    </td>
23
        </td>
24
    <td>
24
 
25
        <?= $log->created_by_name ?>
25
        <td class="-logs-when">
26
    </td>
26
            <?=@date($log->created_on)?>
27
    <td>
27
        </td>
28
        <?= $log->created_on ?>
28
 
29
    </td>
29
        <td class="-logs-message">
30
</tr>
30
 
 
 
31
            <span class="-logs-createdby"><?=$log->created_by_name?></span> 
 
 
32
 
 
 
33
            performed 
 
 
34
            
 
 
35
            <span class="-logs-action"><?=ucfirst($log->action)?></span> 
 
 
36
 
 
 
37
            in 
 
 
38
 
 
 
39
            <span class="-logs-package"><?=ucfirst($log->package)?></span> 
 
 
40
 
 
 
41
            <?=@text('Component')?>&rsquo;s <?=ucfirst($log->name)?>.
 
 
42
        </td>
 
 
43
 
 
 
44
        <td class="-logs-item">
 
 
45
 
 
 
46
        <?php if ($log->action != 'delete'): ?>
 
 
47
        <a href="<?=@route('index.php?option=com_'.$log->package.'&view='.$log->name.'&id='.$log->row_id)?>" target="new"><?=$log->title?></a>
 
 
48
        <?php else: ?>
 
 
49
            <span class="-logs-deleted"><?=$log->title?></span>
 
 
50
        <?php endif ?>
 
 
51
 
 
 
52
        </td>
 
 
53
        
 
 
54
    </tr>
31
<? endforeach; ?>
55
<? endforeach; ?>
10401041
16
            <? foreach($logs as $log) : ?>
16
            <? foreach($logs as $log) : ?>
17
            <div class="activity">
17
            <div class="activity">
18
                <span class="icon icon-16-<?= $log->action ?>"></span>
18
                <span class="icon icon-16-<?= $log->action ?>"></span>
19
                <?= @helper('admin::com.logs.template.helper.message.build', array('row' => $log)) ?>
19
                <?= @helper('com://admin/logs.template.helper.message.build', array('row' => $log)) ?>
20
                <span class="info">
20
                <span class="info">
21
                    <small><?= $log->package.' - '.$log->name ?> | <?= date("H:i", strtotime($log->created_on))
?></small>
21
                    <small><?= $log->package.' - '.$log->name ?> | <?= date("H:i", strtotime($log->created_on))
?></small>
22
                </span>
22
                </span>
10401041
21
            <? foreach($list as $date => $logs) : ?>
21
            <? foreach($list as $date => $logs) : ?>
22
            <? foreach($logs as $log) : ?>
22
            <? foreach($logs as $log) : ?>
23
            <tr class="<?php echo 'row'.$m; ?>" style="line-height: 14px;">
23
            <tr class="<?php echo 'row'.$m; ?>" style="line-height: 14px;">
24
                <td><?= @helper('admin::com.logs.template.helper.message.build', array('row' => $log, 'truncate' => true)) ?></td>
24
                <td><?= @helper('com://admin/logs.template.helper.message.build', array('row' => $log, 'truncate' => true)) ?></td>
25
            </tr>
25
            </tr>
26
            <? $i = $i + 1; $m = (1 - $m); ?>    
26
            <? $i = $i + 1; $m = (1 - $m); ?>    
27
            <? endforeach ?>
27
            <? endforeach ?>
10401041
4
<style src="media://com_logs/css/logs-widget.css" />
4
<style src="media://com_logs/css/logs-widget.css" />
5
 
5
 
6
<? if(count($logs)) : ?>
6
<? if(count($logs)) : ?>
7
    <? foreach ($logs as $log) :
7
    <form action="<?= @route()?>" method="get" class="-koowa-grid">
8
        $list[substr($log->created_on, 0, 10)][] = $log;
8
        <table class="adminlist" style="clear: both;">
9
    endforeach; ?>
9
            <tbody>
 
 
10
                <?
 
 
11
                $timeago = '';
 
 
12
                foreach ($logs as $log) : 
 
 
13
                    $timeago_text = @timeago($log->created_on);
 
 
14
                    $show_timeago = ($timeago != $timeago_text);
 
 
15
                    $timeago = $timeago_text;
10
 
16
 
11
    <div id="logs-logs-widget">
17
                ?>
12
        <? foreach($list as $date => $logs) : ?>
18
                    <?php if ($show_timeago): ?>
13
            <h4><?= @helper('date.humanize', array('date' => $date)) ?></h4>
19
                        <tr>
14
            <? foreach($logs as $log) : ?>
20
                            <td class="-logs-timeago" colspan="4">
15
            <div class="log">
21
                                <?=($show_timeago) ? $timeago_text: ''?>
16
                <span class="icon icon-16-<?= $log->action ?>"></span>
22
                            </td>
17
                <?= @helper('admin::com.logs.template.helper.message.build', array('row' => $log, 'truncate' => true)) ?>
23
                        </tr>
18
            </div>
24
                    <?php endif ?>
19
            <? endforeach ?>
25
 
20
        <? endforeach ?>
26
                    <tr>
21
    </div>
27
                        <td class="-logs-message">
 
 
28
                            On <strong><?=@date($log->created_on)?></strong>,
 
 
29
 
 
 
30
                            <span class="-logs-createdby"><?=$log->created_by_name?></span> 
 
 
31
 
 
 
32
                            performed 
 
 
33
                            
 
 
34
                            <span class="-logs-action"><?=ucfirst($log->action)?></span> 
 
 
35
 
 
 
36
                            in 
 
 
37
 
 
 
38
                            <span class="-logs-package"><?=ucfirst($log->package)?></span> 
 
 
39
 
 
 
40
                            <?=@text('Component')?>&rsquo;s <?=ucfirst($log->name)?> - <a href="<?=@route('index.php?option=com_'.$log->package.'&view='.$log->name.'&id='.$log->row_id)?>" target="new"><?=$log->title?></a>.
 
 
41
                        </td>
 
 
42
                    </tr>
 
 
43
                <? endforeach; ?>
 
 
44
            </tbody>
 
 
45
            
 
 
46
            <tfoot>
 
 
47
                <tr>
 
 
48
                    <td colspan="20">
 
 
49
                        <a href="<?=@route('index.php?option=com_logs&view=logs&layout=default')?>">View All</a>
 
 
50
                    </td>
 
 
51
                </tr>
 
 
52
            </tfoot>
 
 
53
        </table>
 
 
54
    </form>
22
<? endif ?>
55
<? endif ?>
10401041
7
    <? foreach ($terms as $term) : ?>
7
    <? foreach ($terms as $term) : ?>
8
    <? list($component, $view) = explode("_", $term->table) ?>
8
    <? list($component, $view) = explode("_", $term->table) ?>
9
    <li>
9
    <li>
10
        <span><?= $term->count ?> <?= @text('items are tagged with') ?></span>
10
        <span><?= $term->count ?> <?= @text('articles are tagged with') ?></span>
11
        <a  href="<?= @route('option=com_'.$component.'&view='.$view.'&tag='.$term->slug) ?>"
class="weight<?= round($term->count/$total + 1) ?>" ><?= $term->title; ?></a>
11
        <a  href="<?= @route('option=com_'.$component.'&view='.$view.'&tag='.$term->slug) ?>"
class="weight<?= round($term->count/$total + 1) ?>" ><?= $term->title; ?></a>
12
    </li>
12
    </li>
13
    <? endforeach; ?>
13
    <? endforeach; ?>
10401041
25
     *
25
     *
26
     * @var KDatabaseTableDefault
26
     * @var KDatabaseTableDefault
27
     */
27
     */
28
    protected $_table;
28
    protected $_table = null;
29
    
 
 
30
    /**
 
 
31
     * The revisions limit
 
 
32
     *
 
 
33
     * @var integer
 
 
34
     */
 
 
35
    protected $_limit;
 
 
36
 
29
 
37
    /**
30
    /**
38
     * Constructor
31
     * Constructor
...
 
...
 
43
    {
36
    {
44
        parent::__construct($config);
37
        parent::__construct($config);
45
 
38
 
46
        foreach($config as $key => $value) {
39
        foreach($config as $key => $value) 
47
            $this->{'_'.$key} = $value;
40
        {
 
 
41
            if(property_exists($this, '_'.$key)) { 
 
 
42
                $this->{'_'.$key} = $value;
 
 
43
            }
48
        }
44
        }
49
    }
45
    }
50
 
46
 
...
 
...
 
59
    protected function _initialize(KConfig $config)
55
    protected function _initialize(KConfig $config)
60
    {
56
    {
61
        $config->append(array(
57
        $config->append(array(
62
            'table' => KFactory::get('admin::com.versions.database.table.revisions'),
58
            'table' => $this->getService('com://admin/versions.database.table.revisions')
63
            'limit' => 1
 
 
64
        ));
59
        ));
65
 
60
 
66
        parent::_initialize($config);
61
        parent::_initialize($config);
...
 
...
 
84
            foreach($query->where as $condition) {
79
            foreach($query->where as $condition) {
85
                $where[$condition['property']] = $condition['value'];
80
                $where[$condition['property']] = $condition['value'];
86
            }
81
            }
87
                
82
 
88
            if(isset($where['tbl.deleted']) && $where['tbl.deleted'] == 1)
83
            if(isset($where['tbl.deleted']) && $where['tbl.deleted'] == 1)
89
            {
84
            {
90
                  $table = $context->caller;
85
                  $table = $context->caller;
...
 
...
 
98
                      $rowset = $table->getRowset();
93
                      $rowset = $table->getRowset();
99
 
94
 
100
                    foreach($revisions as $row) 
95
                    foreach($revisions as $row) 
101
                    {  
96
                    {
102
                        $row = $rowset->getRow()
97
                        $options = array(
103
                                   ->setData($row->data, false)
98
                            'data'   => $row->data,
104
                                   ->setStatus(KDatabase::STATUS_DELETED);
99
                            'status' => KDatabase::STATUS_DELETED,
105
                             
100
                            'new'    => false,   
106
                        $rowset->insert($row);
101
                        );
 
 
102
                        
 
 
103
                        $rowset->insert($rowset->getRow($options));
107
                    }
104
                    }
108
 
105
 
109
                      $context->data = $rowset;
106
                      $context->data = $rowset;
...
 
...
 
127
     */
124
     */
128
    protected function _afterTableInsert(KCommandContext $context)
125
    protected function _afterTableInsert(KCommandContext $context)
129
    {
126
    {
130
        if($this->_limit > 1)
127
        if($this->_countRevisions(KDatabase::STATUS_CREATED) == 0) {
131
        {
128
            $this->_insertRevision(KDatabase::STATUS_CREATED);
132
            if($this->_countRevisions(KDatabase::STATUS_CREATED) == 0) {
 
 
133
                $this->_insertRevision(KDatabase::STATUS_CREATED);
 
 
134
            }
 
 
135
        }
129
        }
136
    }
130
    }
137
 
131
 
...
 
...
 
146
     */
140
     */
147
    protected function _beforeTableUpdate(KCommandContext $context)
141
    protected function _beforeTableUpdate(KCommandContext $context)
148
    {
142
    {
149
        if($this->getTable()->count($this->id))
143
        $table = clone $this->getTable();
 
 
144
        if($table->count($this->id))
150
        {
145
        {
151
            if($this->_limit > 1)
146
            if ($this->_countRevisions() == 0) {
152
            {
147
                $this->_insertRevision(KDatabase::STATUS_CREATED);
153
                if ($this->_countRevisions() == 0) {
148
            }
154
                   $this->_insertRevision(KDatabase::STATUS_CREATED);
149
        }
155
                }
 
 
156
            }
 
 
157
        }
 
 
158
        else
150
        else
159
        {     
151
        {
160
            if($this->_limit > 0)
152
            if($this->_countRevisions(KDatabase::STATUS_DELETED) == 1)
161
            {
153
            {
162
                if($this->_countRevisions(KDatabase::STATUS_DELETED) == 1)
154
                //Restore the row
163
                {
155
                $this->getTable()->getRow()->setData($this->getData())->save();
164
                    //Restore the row
 
 
165
                    $this->getTable()->getRow()->setData($this->getData())->save();
 
 
166
 
156
 
167
                    //Set the row status to updated
157
                //Set the row status to updated
168
                    $this->setStatus(KDatabase::STATUS_UPDATED);
158
                $this->setStatus(KDatabase::STATUS_UPDATED);
169
 
159
 
170
                    //Delete the revision
160
                //Delete the revision
171
                    $this->_deleteRevisions(KDatabase::STATUS_DELETED);
161
                $this->_deleteRevisions(KDatabase::STATUS_DELETED);
172
 
162
 
173
                    return false;
163
                return false;
174
                }    
164
            }
175
            }
 
 
176
        }
165
        }
177
    }
166
    }
178
 
167
 
...
 
...
 
186
     */
175
     */
187
    protected function _afterTableUpdate(KCommandContext $context)
176
    protected function _afterTableUpdate(KCommandContext $context)
188
    {
177
    {
189
        if($this->_limit > 1)
178
        // Only insert new revision if the database was updated
190
        {
179
        if ((bool) $context->affected) {
191
            // Only insert new revision if the database was updated
180
            $this->_insertRevision(KDatabase::STATUS_UPDATED);
192
            if ((bool) $context->affected) {
181
        }
193
                $this->_insertRevision(KDatabase::STATUS_UPDATED);
 
 
194
            }
 
 
195
        }
 
 
196
    }
182
    }
197
 
183
 
198
    /**
184
    /**
...
 
...
 
206
     */
192
     */
207
    protected function _beforeTableDelete(KCommandContext $context)
193
    protected function _beforeTableDelete(KCommandContext $context)
208
    {
194
    {
209
        if ($this->getTable()->count($this->id))
195
        $table = clone $this->getTable();
 
 
196
           if ($table->count($this->id))
210
           {
197
           {
211
               if($this->_limit > 1)
198
               if($this->_countRevisions() == 0) {
212
            {
199
                    $this->_insertRevision(KDatabase::STATUS_CREATED);
213
                   if($this->_countRevisions() == 0) {
200
               }
214
                       $this->_insertRevision(KDatabase::STATUS_CREATED);
201
        }
215
                   }
202
        else
216
            }
203
        {
217
         }
204
             if($this->_countRevisions(KDatabase::STATUS_DELETED) == 1)
218
         else
 
 
219
         {
 
 
220
            if($this->_countRevisions(KDatabase::STATUS_DELETED) == 1)
 
 
221
            {
205
            {
222
                $context->affected = $this->_deleteRevisions();
206
                $context->affected = $this->_deleteRevisions();
223
                return false;
207
                return false;
224
            }
208
            }
225
        }
209
        }
...
 
...
 
236
     */
220
     */
237
    protected function _afterTableDelete(KCommandContext $context)
221
    protected function _afterTableDelete(KCommandContext $context)
238
    {
222
    {
239
        if($this->_limit > 0) {
223
        $this->_insertRevision(KDatabase::STATUS_DELETED);
240
            $this->_insertRevision(KDatabase::STATUS_DELETED);
 
 
241
        }
 
 
242
    }
224
    }
243
 
225
 
244
    /**
226
    /**
10401041
18
 * @subpackage     Versions
18
 * @subpackage     Versions
19
 */
19
 */
20
 
20
 
21
echo KFactory::get('admin::com.versions.dispatcher')->dispatch();
21
echo KService::get('com://admin/versions.dispatcher')->dispatch();
10401041
1
table.adminlist thead tr.filters { background-color: #EEE; }
1
/* $Id$ */
 
 
2
 
 
 
3
 
 
 
4
td.-logs-timeago,
 
 
5
table.adminlist tbody tr:nth-child(even) td.-logs-timeago {
 
 
6
    height: auto;
 
 
7
    text-align: left;    
 
 
8
    font-weight: bold;
 
 
9
    background-color: #ededed;
 
 
10
    border-bottom: 1px solid #dddddd;
 
 
11
}
 
 
12
 
 
 
13
.-logs-when {
 
 
14
    font-weight: bold;
 
 
15
    text-align: center;
 
 
16
}
 
 
17
 
 
 
18
.-logs-createdby,
 
 
19
.-logs-action {
 
 
20
    font-weight: bold;
 
 
21
}
 
 
22
 
 
 
23
th.-logs-when {
 
 
24
    width: 15%;
 
 
25
}
 
 
26
 
 
 
27
th.-logs-message {
 
 
28
    width: 30%;
 
 
29
}
 
 
30
 
 
 
31
.-logs-item,
 
 
32
table.adminlist thead th.-logs-item {
 
 
33
    text-align: left;
 
 
34
}
 
 
35
 
 
 
36
.-logs-deleted {
 
 
37
    text-decoration: line-through;
 
 
38
}