90 lines
2.2 KiB
PHP
90 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Common\Model;
|
|
|
|
use \Gy_Library\DBCont;
|
|
|
|
class SecondaryTitleModel extends \Gy_Library\GyListModel
|
|
{
|
|
protected $model_name = '搜索关键词';
|
|
|
|
protected $_auto = array(
|
|
// array('created_at', "date", parent::MODEL_INSERT, 'function', array('Y-m-d H:i:s')),
|
|
array('create_time', 'getTime', 1, 'callback')
|
|
);
|
|
|
|
protected $_validate = array(
|
|
array('name', 'require', '请填写名称'),
|
|
);
|
|
|
|
protected $_delete_auto = array(
|
|
array('delete', 'SecondaryNews', array('id' => 'secondary_id')),
|
|
);
|
|
|
|
public function newTitle($data)
|
|
{
|
|
return $this->createAdd($data);
|
|
}
|
|
|
|
public function updateTitle($data)
|
|
{
|
|
return $this->createSave($data);
|
|
}
|
|
|
|
protected function getTime()
|
|
{
|
|
$time = time();
|
|
$datetime = date("Y-m-d H:i:s", $time);
|
|
return $datetime;
|
|
}
|
|
|
|
public function getConditionList($id)
|
|
{
|
|
return $this->join('__SECONDARY_NEWS__ ON __SECONDARY_TITLE__.id = __SECONDARY_NEWS__.secondary_id')
|
|
->where(array('tz_secondary_title.id' => $id))
|
|
->field('tz_secondary_news.*')->find();
|
|
}
|
|
|
|
public function getKeywordName($id)
|
|
{
|
|
$k_model = D('Keywords');
|
|
$k_data = $k_model->where(array('id' => $id))->find();
|
|
return $k_data['name'];
|
|
}
|
|
|
|
public function getCateName($id)
|
|
{
|
|
$k_model = D('NewsCate');
|
|
$k_data = $k_model->where(array('id' => $id))->find();
|
|
return $k_data['name'];
|
|
}
|
|
|
|
public function extraKeyword($str)
|
|
{
|
|
$str = trim($str);
|
|
if ($str == '') {
|
|
return '';
|
|
}
|
|
$arr = explode(',', $str);
|
|
foreach ($arr as &$a) {
|
|
$a = $this->getKeywordName($a);
|
|
}
|
|
$re = join(',', $arr);
|
|
return $re;
|
|
}
|
|
|
|
public function extraCate($str)
|
|
{
|
|
$str = trim($str);
|
|
if ($str == '') {
|
|
return '';
|
|
}
|
|
$arr = explode(',', $str);
|
|
foreach ($arr as &$a) {
|
|
$a = $this->getCateName($a);
|
|
}
|
|
$re = join(',', $arr);
|
|
return $re;
|
|
}
|
|
}
|