本文整理汇总了PHP中Meta::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Meta::parse方法的具体用法?PHP Meta::parse怎么用?PHP Meta::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Meta
的用法示例。
在下文中一共展示了Meta::parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
$id = $this->get('id');
$state = (string) $this->get('state');
if (!$this->is_moderator()) {
throw new ErrorApi(ErrorApi::INSUFFICIENT_RIGHTS);
}
if (empty($id) || empty($state)) {
throw new ErrorApi(ErrorApi::MISSING_INPUT);
}
$state = Meta::parse($state);
if (empty($state)) {
throw new ErrorApi(ErrorApi::INCORRECT_INPUT);
}
$this->db->update('art', array('sortdate' => $this->db->unix_to_date()), $id);
$this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_APPROVED);
$this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_UNAPPROVED);
$this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_DISAPPROVED);
$this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_DELETED);
$this->add_meta(Meta::ART, $id, Meta::STATE, $state);
$cache = new \Memcached("access_checker");
$cache->addServer("localhost", 11211);
$cache->delete('is_pic_safe_' . $this->db->get_field('art', 'md5', $id));
$this->set_success(true);
}
示例2: get_filters
protected function get_filters($params)
{
if (!empty($params['filter']) && is_array($params['filter'])) {
$this->parse_date_filters($params['filter'], array('date'));
foreach ($params['filter'] as &$filter) {
if (!isset($filter['name']) || !isset($filter['type']) || !isset($filter['value'])) {
continue;
}
if (in_array($filter['name'], $this->local_filtered_variables) && Meta::parse($filter['type'])) {
if ($filter['name'] == 'date') {
$filter['name'] = 'sortdate';
$filter['value'] = $this->db->unix_to_date($filter['value']);
}
if ($filter['name'] == 'user') {
$filter['name'] = 'id_user';
$value = $this->db->get_field('user', 'id', 'login = ?', $filter['value']);
if (empty($value) && Meta::parse($filter['type']) == Meta::IS) {
throw new ErrorApi('Пользователя ' . $filter['value'] . ' не существует.', ErrorApi::INCORRECT_INPUT);
}
$filter['value'] = $value;
}
$this->local_filters[] = $filter['name'] . ' ' . Meta::parse($filter['type']) . ' ?';
$this->local_filter_vars[] = $filter['value'];
$filter = null;
}
}
unset($filter);
}
return parent::get_filters($params);
}
示例3: process
public function process()
{
if ($this->table === null) {
$this->add_error(ErrorApi::INCORRECT_URL);
return;
}
$ids = (array) $this->get('id');
foreach ($ids as &$id) {
if (!is_numeric($id)) {
$id = null;
}
}
$ids = array_filter($ids);
if (empty($ids)) {
$this->add_error(ErrorApi::INCORRECT_INPUT);
return;
}
$data = $this->get_data($ids);
if ($this->get('add_tags')) {
$tags = $this->db->join('art_tag', 'at.id = m.meta')->join($this->table . '_tag_count', 'at.id = id_tag')->get_table('meta', array('m.id_item', 'at.*', 'count'), 'm.item_type = ' . Meta::parse(strtoupper($this->table)) . ' and m.meta_type = ' . Meta::ART_TAG . ' and ' . $this->db->array_in('m.id_item', $ids), $ids);
foreach ($data as &$item) {
$item['tag'] = array();
}
unset($item);
foreach ($tags as $tag) {
$link =& $data[$tag['id_item']]['tag'];
unset($tag['id_item']);
unset($tag['id']);
$link[] = $tag;
}
}
$this->add_answer('data', $data);
$this->set_success(true);
}
示例4: process
public function process()
{
$id = $this->get('id');
if (!$this->is_moderator() && $this->get('remove')) {
throw new ErrorApi(ErrorApi::INSUFFICIENT_RIGHTS);
}
if (empty($id) || !$this->have_changes()) {
throw new ErrorApi(ErrorApi::MISSING_INPUT);
}
if (!$this->check_pool($id)) {
throw new ErrorApi(ErrorApi::INCORRECT_INPUT);
}
$meta = Meta::parse($this->table);
foreach ((array) $this->get('add') as $item) {
if (!$this->in_pool($id, $item['id'])) {
if ($this->add_item($id, $item)) {
$this->add_meta(Meta::ART, (int) $item['id'], $meta, $id);
}
}
}
foreach ((array) $this->get('remove') as $item) {
if ($this->remove_item($id, (int) $item)) {
$this->remove_meta(Meta::ART, (int) $item, $meta, $id);
}
}
if ($this->get('title')) {
$this->db->update($this->table, array('title' => $this->get('title')), $id);
}
if ($this->get('text') !== null) {
$this->db->update($this->table, array('text' => $this->get('text')), $id);
}
$this->set_success(true);
}
示例5: get_filters
protected function get_filters()
{
$filters = (array) $this->get('filter');
foreach ($filters as $key => &$filter) {
$filter = (array) $filter;
if (!in_array($key, $this->legal_filter)) {
$filter = null;
}
if ($key == 'area') {
foreach ($filter as &$item) {
if (!is_numeric($item)) {
$item = Meta::parse($item);
}
}
unset($item);
$filter = array_filter($filter);
}
}
unset($filter);
return array_filter($filters);
}