HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbExtendedTooltipAction.php
Go to the documentation of this file.
1 <?php
13 class TbExtendedTooltipAction extends CAction
14 {
20  public $tooltipTable = 'tbl_tooltip';
21 
26  public $connectionID = 'db';
27 
31  protected $_db;
32 
36  public function run()
37  {
38  $key = yii::app()->request->getParam('name');
39  $tooltip = Yii::app()->request->getParam('value');
40  if (!$key || !$tooltip) {
41  throw new CHttpException(404, Yii::t('zii', 'Unauthorized request'));
42  }
43 
44  if (!$this->getDbConnection()
45  ->createCommand()
46  ->update($this->tooltipTable, array('tooltip' => $tooltip), 'tooltip_key=:key', array(':key' => $key))
47  ) {
48  $this->getDbConnection()
49  ->createCommand()
50  ->insert($this->tooltipTable, array('tooltip_key' => $key, 'tooltip' => $tooltip));
51  }
52  }
53 
63  protected function getDbConnection()
64  {
65  if ($this->_db === null) {
66  $this->_db = Yii::app()->getComponent('db');
67  if (!$this->_db instanceof CDbConnection) {
68  throw new CException(Yii::t(
69  'zii',
70  'The "db" application component must be configured to be a CDbConnection object.'
71  ));
72  }
73  }
74  return $this->_db;
75  }
76 }