Exemplo n.º 1
0
 protected function get_params(Query $query)
 {
     $legal = $query->all();
     unset($legal['page']);
     $legal = array_keys($legal);
     $search = array();
     foreach ($query->get() as $key => $items) {
         $negated = '';
         if (strpos($key, '-') === 0) {
             $key = substr($key, 1);
             $negated = '-';
         }
         if (!in_array($key, $legal)) {
             continue;
         }
         foreach ((array) $items as $item) {
             $search[] = $negated . ($key == 'tag' ? $item : $key . ':' . $item);
         }
     }
     // Если отдельный арт, то добавим страницу на которой он был
     if ($query->get('pos')) {
         $page = ceil($query->get('pos') / $query->per_page());
         if ($page > 1) {
             $search[] = 'page:' . $page;
         }
     }
     $this->set_param('query', implode(' ', $search));
 }
Exemplo n.º 2
0
Arquivo: Art.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     if ($query->get('manga')) {
         $this->manga = (int) $query->get('manga');
     } elseif ($query->get('pack')) {
         $this->pack = (int) $query->get('pack');
     }
     parent::get_params($query);
 }
Exemplo n.º 3
0
 protected function get_params(Query $query)
 {
     if ($query->get('page')) {
         $this->page = (int) $query->get('page');
     }
     $this->base_url = '/' . implode('/', $query->url()) . '?';
     $get = $query->get();
     unset($get['page']);
     foreach ($get as $key => $value) {
         $this->base_url .= $key . '=' . $value . '&';
     }
 }
Exemplo n.º 4
0
Arquivo: Add.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $url = $query->get('url');
     $name = $query->get('name');
     if (empty($url) || empty($name)) {
         $this->set_error(420);
         return;
     }
     $session = Session::getInstance();
     $cookie = $session->get_hash();
     $order = Database::get_field('head_menu_user', 'max(`order`)', 'cookie = ?', $cookie);
     Database::insert('head_menu_user', ['cookie' => $cookie, 'name' => $name, 'url' => $url, 'order' => (int) $order + 1]);
     $this->set_success(true);
     $this->set_params(['id' => Database::last_id(), 'name' => $name, 'url' => $url]);
 }
Exemplo n.º 5
0
Arquivo: Help.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     if (Session::getInstance()->is_moderator()) {
         Database::replace('help', array('key' => 'add', 'text' => (string) $query->get('text')), array('key'));
     }
     $this->set_success(true);
 }
Exemplo n.º 6
0
	protected function get_modules(Query $query) {
		$url = $query->url();
		array_shift($url);
		$url = array_filter($url);

		if (empty($url)) {
			return array();
		}

		$last = array_pop($url);
		$last = preg_replace_callback('/_([a-z])/', function($res){
			return strtoupper($res[1]);
		}, $last);
		$url[] = $last;

		$class = implode('', array_map('ucfirst', $url));
		$class = \Autoload::getDefaultNamespace() . '\Module\Ajax' . $class;

		if (!class_exists($class)) {
			if ($query->get('format') == 'json') {
				return new AjaxJsonError($query);
			} else {
				return new AjaxError($query);
			}
		}

		return new $class($query);
	}
Exemplo n.º 7
0
 protected function get_params(Query $query)
 {
     $this->set_param('is_variation_list', false);
     if (is_numeric($query->url(0))) {
         $this->set_param('mode', false);
         $this->set_param('id', $query->url(0));
         $this->id_art = $query->url(0);
     } else {
         if (!$query->get_pool_mode()) {
             if (!$query->is_variation_list() || !Session::getInstance()->is_moderator()) {
                 $this->disable();
             } else {
                 $this->set_param('is_variation_list', true);
                 $this->set_param('id', $query->get('parent'));
             }
         } else {
             $this->set_param('mode', $query->get_pool_mode());
             $this->set_param('id', $query->get_pool_value());
             if ($query->get_pool_mode() == 'artist') {
                 $this->id_artist = $query->get_pool_value();
             }
             if ($query->is_pool_full_view()) {
                 $this->set_param('is_list', true);
             } else {
                 $this->set_param('is_list', false);
                 $this->set_param('list_link', $query->get_pool_mode() . '=' . $query->get_pool_value() . '&per_page=all');
             }
         }
     }
     $this->set_param('moderator', Session::getInstance()->is_moderator());
 }
Exemplo n.º 8
0
 protected function get_params(Query $query)
 {
     $section = $query->get('section');
     $key = $query->get('key');
     $value = $query->get('value');
     $values = (array) $query->get('values');
     if (empty($values)) {
         $values = [$key => $value];
     }
     foreach ($values as $key => $value) {
         if (preg_match('/[^a-z_\\d]/ui', $section)) {
             $this->set_error(430);
             return;
         }
         $session = Session::getInstance();
         $session->set($section, $key, $value);
     }
     $this->set_success(true);
 }
Exemplo n.º 9
0
 protected function get_params(Query $query)
 {
     $id = $query->get('id');
     if (empty($id)) {
         $this->set_error(420);
         return;
     }
     Database::delete('head_menu_user', $id);
     $this->set_success(true);
 }
Exemplo n.º 10
0
 protected function get_params(Query $query)
 {
     $this->set_param('query', $query->to_url_string());
     $this->set_param('start', max(1, $query->get('start')));
     $this->set_param('auto', Config::getInstance()->get('slideshow', 'auto'));
     $delay = Config::getInstance()->get('slideshow', 'delay');
     if ($delay < 10) {
         $delay = '0' . $delay;
     }
     $this->set_param('delay', $delay);
 }
Exemplo n.º 11
0
Arquivo: Save.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $id = $query->get('id');
     $url = $query->get('url');
     $name = $query->get('name');
     $order = $query->get('order');
     if (empty($url) || empty($name) || empty($id) || empty($order)) {
         $this->set_error(420);
         return;
     }
     Database::update('head_menu_user', ['url' => $url, 'name' => $name], $id);
     $session = Session::getInstance();
     $cookie = $session->get_hash();
     $items = Database::order('order', 'asc')->get_table('head_menu_user', array('id', 'order'), 'cookie = ?', $cookie);
     foreach ($items as &$item) {
         if ($item['id'] == $id) {
             $item['new_order'] = $order;
         }
     }
     unset($item);
     $new_order = 1;
     foreach ($items as &$item) {
         if (!empty($item['new_order'])) {
             continue;
         }
         if ($new_order == $order) {
             $new_order++;
         }
         $item['new_order'] = $new_order;
         $new_order++;
     }
     unset($item);
     foreach ($items as $item) {
         if ($item['new_order'] != $item['order']) {
             Database::update('head_menu_user', ['order' => $item['new_order']], $item['id']);
         }
     }
     $this->set_success(true);
     $this->set_params(['name' => $name, 'url' => $url, 'order' => $items]);
 }
Exemplo n.º 12
0
	protected function get_modules(Query $query) {
		$type = (string) $query->get('type');
		$type = explode('_', $type);
		$type = implode('', array_map('ucfirst', $type));

        $class = \Autoload::getDefaultNamespace() . '\Module\Download' . $type;

		if (!class_exists($class)) {
			return [];
		}

		return new $class($query);
	}
Exemplo n.º 13
0
Arquivo: Tag.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     if ($query->get('page')) {
         $this->page = (int) $query->get('page');
     }
     if ($query->get('filter')) {
         $this->filter = (string) $query->get('filter');
     }
     if ($query->get('strict')) {
         $this->strict = true;
     }
     if ($query->get('namesort')) {
         $this->sort = 'name';
     }
     if ($query->get('reverse')) {
         $this->order = 'asc';
     }
     $this->set_param('filter', $this->filter);
     $this->set_param('strict', $this->strict);
     $this->set_param('namesort', (bool) $query->get('namesort'));
     $this->set_param('reverse', (bool) $query->get('reverse'));
     $this->set_param('colors', $this->color);
 }
Exemplo n.º 14
0
Arquivo: Edit.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $id = $query->get('id');
     if (empty($id)) {
         return;
     }
     $session = Session::getInstance();
     $cookie = $session->get_hash();
     $item = Database::get_full_row('head_menu_user', 'cookie = ? and id = ?', [$cookie, $id]);
     foreach ($item as $key => $value) {
         $this->set_param($key, $value);
     }
     $order = Database::order('order', 'asc')->get_vector('head_menu_user', ['id', 'order'], 'cookie = ?', $cookie);
     $set_order = [];
     $i = 0;
     foreach ($order as $order_id => $value) {
         $set_order[] = ['selected' => $order_id == $id, 'order' => ++$i];
     }
     $this->set_param('order', $set_order);
 }
Exemplo n.º 15
0
Arquivo: List.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     if ($query->get('comment_page')) {
         $page = $query->get('comment_page');
         if ($page == 'all') {
             $this->per_page = 99999;
             $page = 1;
         }
         $this->page = max($this->page, (int) $page);
     }
     if ($query->url(0)) {
         $this->id = (int) $query->url(0);
     }
     if ($query->get('id_art')) {
         $this->id = (int) $query->get('id_art');
     }
     if ($query->get('id_comment')) {
         $this->id_comment = (int) $query->get('id_comment');
     }
 }
Exemplo n.º 16
0
Arquivo: Rate.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->id = $query->get('id');
     $this->approve = $query->get('approve');
 }
Exemplo n.º 17
0
 protected function get_params(Query $query)
 {
     $this->id = $query->get('id');
     $this->mode = $query->get('mode');
 }
Exemplo n.º 18
0
	protected function get_params(Query $query) {
		$this->id = (int) $query->get('id');
	}
Exemplo n.º 19
0
Arquivo: Tag.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->params = $query->get();
     unset($this->params['format']);
 }
Exemplo n.º 20
0
 protected function get_params(Query $query)
 {
     if ((int) $query->get('page')) {
         $this->page = (int) $query->get('page');
     }
 }
Exemplo n.º 21
0
Arquivo: Tool.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->set_param('query', $query->to_url_string());
     $this->set_param('mode', $query->get('mode'));
     $this->set_param('slideshow_enabled', !$query->get('mode') || $query->get('mode') == 'art');
 }
Exemplo n.º 22
0
Arquivo: Merge.php Projeto: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->id = $query->get('id');
     $this->set_param('id', $this->id);
 }
Exemplo n.º 23
0
 protected function get_params(Query $query)
 {
     $this->raw_term = $query->get('term');
     $this->term = (string) $this->parse_raw_term();
 }