本文整理汇总了PHP中MY_Model::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP MY_Model::getOptions方法的具体用法?PHP MY_Model::getOptions怎么用?PHP MY_Model::getOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MY_Model
的用法示例。
在下文中一共展示了MY_Model::getOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_popup_table_data
/**
* return dashbord popup sorted table
* @return json
* @author Ruslan Ushakov
**/
public function get_popup_table_data()
{
$result = array();
$this->load->model('alert_model');
$this->load->model('ranking_model');
$this->load->model('batches_model');
$sort_by_prev = $this->input->post('sort_by');
$sort_dir = $this->input->post('sort_dir');
if ($sort_dir != 'desc') {
$sort_dir = 'asc';
}
$allowed_sort_by = array('name', 'type', 'findable');
if (!in_array($sort_by_prev, $allowed_sort_by)) {
$sort_by = 'name';
} else {
$sort_by = $sort_by_prev;
}
$user_id = $this->ion_auth->get_user_id();
if ($sort_by == 'findable') {
if ($sort_dir == 'asc') {
$sort_str = $sort_by . ',desc';
} else {
$sort_str = $sort_by . ',asc';
}
$findable_alerts = $this->alert_model->getAllUnserialized($user_id, $sort_str, array('type' => array('summary')));
$other_alerts = $this->alert_model->getAllUnserialized($user_id, $sort_str, array('type' => array('out_of_stock', 'negative_review', 'pricing_report')));
if ($sort_dir == 'asc') {
$alerts = array_merge($findable_alerts, $other_alerts);
} else {
$alerts = array_merge($other_alerts, $findable_alerts);
}
} else {
$alerts = $this->alert_model->getAllUnserialized($user_id, $sort_by . ',' . $sort_dir, array('type' => array('summary', 'out_of_stock', 'negative_review', 'pricing_report')));
}
// get keywords string
foreach ($alerts as &$alert) {
$options = Alert_model::extractSearchCriteria($alert->options);
if (!empty($options['rank_term'])) {
$terms = \MY_Model::getOptions($this->ranking_model->getKeywordsNamesByIds($options['rank_term']), 'id', 'title');
} else {
$terms = null;
}
$alert->keywords_string = empty($terms) ? '' : join(', ', $terms);
$alert->type_option_title = array_search($alert->type, Alert_model::$types) ?: ucwords(str_replace("_", " ", $alert->type));
}
if ($sort_by_prev == 'brand' && $sort_dir == 'asc') {
usort($alerts, array($this, 'sort_alerts_by_brands_asc'));
} elseif ($sort_by_prev == 'brand' && $sort_dir == 'desc') {
usort($alerts, array($this, 'sort_alerts_by_brands_desc'));
} elseif ($sort_by_prev == 'keyword' && $sort_dir == 'asc') {
usort($alerts, array($this, 'sort_alerts_by_keywords_asc'));
} elseif ($sort_by_prev == 'keyword' && $sort_dir == 'desc') {
usort($alerts, array($this, 'sort_alerts_by_keywords_desc'));
}
$result['alerts_table'] = $this->load->view('dashboard/elements/popup-alert-table', array('alerts' => $alerts), true);
$this->output->set_content_type('application/json')->set_output(json_encode($result));
}
示例2: getKeywordsOptions
protected function getKeywordsOptions()
{
if (count($this->options['rank_term'])) {
return \MY_Model::getOptions($this->getRankingModel()->getKeywordsNamesByIds($this->options['rank_term']), 'id', 'title');
}
return array();
}