/** * generate box to save it * @return \wtb_seo_box */ public function generateBox() { $box = new wtb_seo_box(); for ($int = 1; $int <= 3; $int++) { $section = new wtb_seo_box_section($int); // keyword $section->keyword = ''; $inputName = $section->getInfoKey('keyword'); if (!empty($_POST[$inputName])) { $section->keyword = trim($_POST[$inputName]); $section->density = $this->getFromPostRequest($section->getInfoKey('density')); $section->score = $this->getFromPostRequest($section->getInfoKey('score')); $section->wdf = $this->getFromPostRequest($section->getInfoKey('wdf')); $section->idf = $this->getFromPostRequest($section->getInfoKey('idf')); // parameters $section->parameters = array(); $paramsInputName = $section->getInfoKey('checkboxes'); if (!empty($_POST[$paramsInputName]) and is_array($_POST[$paramsInputName])) { $section->parameters = $_POST[$paramsInputName]; } } $box->addSection($section); } return $box; }
public function getSection($int) { $section = new wtb_seo_box_section($int); $section->keyword = esc_attr($this->getMetaData($section->getInfoKey('keyword'))); if (empty($section->keyword)) { return false; } $section->density = esc_attr($this->getMetaData($section->getInfoKey('density'))); $section->score = esc_attr($this->getMetaData($section->getInfoKey('score'))); $section->wdf = esc_attr($this->getMetaData($section->getInfoKey('wdf'))); $section->idf = esc_attr($this->getMetaData($section->getInfoKey('idf'))); $section->parameters = array(); $params = (array) json_decode($this->getMetaData($section->getInfoKey('checkboxes'))); if (!is_array($params) or empty($params)) { $params = array(); } foreach ($params as $key => $value) { $section->parameters[$key] = $value; } return $section; }