protected function make_tooltip($data) { $return = array(); $data['comment'] = array_reverse($data['comment']); foreach ($data['comment'] as $comment) { $username = $comment['username']; $text = new Text($comment['text']); $return[] = $comment['sortdate'] . ', ' . '[b]' . $username . "[/b]:\n " . $text->trim()->links2bb(); } return implode("\n\n", $return); }
public function recieve_data($data) { if (!$data['count']) { return; } parent::recieve_data($data['data']); if (!empty($data['data']['source'])) { $source = new Text($data['data']['source']); $this->set_param('source', $source->links2html()); } if (!empty($data['data']['weight'])) { $this->set_param('weight', $this->format_weight($data['data']['weight'])); } if (isset($data['data']['state']) && is_array($data['data']['state']) && in_array('approved', $data['data']['state']) && in_array('tagged', $data['data']['state'])) { $this->set_param('date_main', $this->format_date($data['data']['sortdate'])); } if (!empty($data['data']['created'])) { $this->set_param('created', $this->format_date($data['data']['created'])); } }
protected function get_description($data) { $text = new Text($data['comment']['text']); $text->format_rss(); return '<![CDATA[' . $text . ']]>'; }
public function recieve_data($data) { if (!empty($data['data']['title'])) { $this->search[0] .= $data['data']['title']; } elseif (!empty($data['data']['artist'])) { $this->search[0] .= $data['data']['artist']; } else { $this->search[0] .= '(не найдено)'; } if (!empty($data['data']['weight'])) { $this->set_param('weight', $this->format_weight($data['data']['weight'])); $this->set_param('pool_mode', $this->get_query()->get_pool_mode()); $this->set_param('pool_value', $this->get_query()->get_pool_value()); } if (!empty($data['data']['text'])) { $text = new Text($data['data']['text']); $text->format(); $this->set_param('text', $text); } $this->set_param('query', implode(', ', $this->search)); }
protected function get_filter_values(&$filters) { $fetch = array(); $value_needed = Meta::value_needed(); foreach ($filters as $filter) { if (!in_array($filter['meta_type'], $value_needed)) { continue; } if (!isset($fetch[$filter['name']])) { $fetch[$filter['name']] = array(); } $fetch[$filter['name']][] = $filter['value']; } foreach ($fetch as $type => $names) { $table = $type == 'translator' ? 'user' : $type; $field = $type == 'translator' ? 'login' : 'name'; $fetched = (array) $this->db->get_vector($table, array($field, 'id'), $this->db->array_in($field, $names), $names); if ($table == 'art_tag' && count($fetched) != count($fetch[$table])) { $variants = (array) $this->db->get_vector('art_tag_variant', array('name', 'id_tag'), $this->db->array_in('name', $names), $names); $fetched = $fetched + $variants; } $fetch[$type] = array(); foreach ($fetched as $key => $item) { $key = new Text($key); $fetch[$type][(string) $key->lower()] = $item; } } foreach ($filters as &$filter) { if (!in_array($filter['meta_type'], $value_needed)) { continue; } $compare_value = new Text($filter['value']); $compare_value = (string) $compare_value->lower(); if (empty($fetch[$filter['name']]) || empty($fetch[$filter['name']][$compare_value])) { if ($filter['operator'] == Meta::IS) { switch ($filter['meta_type']) { case Meta::ART_TAG: $text = 'Тега "' . $filter['value'] . '" не существует.'; break; case Meta::STATE: $text = 'Состояния "' . $filter['value'] . '" не существует.'; break; case Meta::TRANSLATOR: $text = 'Пользователя "' . $filter['value'] . '" не существует.'; break; default: $text = $filter['name'] . ' "' . $filter['value'] . '" не существует.'; break; } throw new ErrorApi($text, ErrorApi::INCORRECT_INPUT); } $filter = null; continue; } $filter['value'] = $fetch[$filter['name']][$compare_value]; } unset($filter); $filters = array_filter($filters); }
protected function parse_raw_term() { $term = new Text($this->raw_term); return $term->lower()->trim()->cut_on("\n\r"); }