Example #1
0
File: Html.php Project: 4otaku/art
 protected function get_modules(Query $query)
 {
     if ($query->url(0) == 'slideshow') {
         return array('body' => new HtmlSlideshow($query));
     }
     return array('header' => new HtmlHeader($query), 'body' => new HtmlBody($query), 'footer' => new HtmlFooter($query));
 }
Example #2
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);
	}
Example #3
0
File: Help.php Project: 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);
 }
Example #4
0
File: Item.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->set_param('query', $query->to_url_string());
     $this->set_param('id', $query->url(0));
     $this->set_param('next', false);
     $this->set_param('prev', false);
 }
Example #5
0
File: Pool.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $parsed = $query->parsed();
     if (!empty($parsed['tag']['is'])) {
         $this->set_param('tags', implode(' ', $parsed['tag']['is']) . ' ');
     } else {
         $this->set_param('tags', '');
     }
 }
Example #6
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);
 }
Example #7
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);
 }
Example #8
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 . '&';
     }
 }
Example #9
0
File: Main.php Project: 4otaku/art
 protected function get_modules(Query $query)
 {
     if ($query->url(0) == 'download') {
         return new Download($query);
     }
     if ($query->url(0) == 'ajax') {
         return new Ajax($query);
     }
     if ($query->url(0) == 'rss') {
         return new Rss($query);
     }
     return new Html($query);
 }
Example #10
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);
	}
Example #11
0
File: Add.php Project: 4otaku/art
 protected function get_modules(Query $query)
 {
     if ($query->url(1) == 'group') {
         return new HtmlAddGroup($query);
     }
     if ($query->url(1) == 'pack') {
         return new HtmlAddPack($query);
     }
     if ($query->url(1) == 'manga') {
         return new HtmlAddManga($query);
     }
     return new HtmlAddArt($query);
 }
Example #12
0
File: Form.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $data = Config::getInstance()->get();
     if (isset($data['default']['name'])) {
         $this->set_param('name', $data['default']['name']);
     } elseif (isset($data['user']['login'])) {
         $this->set_param('name', $data['user']['login']);
     }
     if (isset($data['default']['mail'])) {
         $this->set_param('mail', $data['default']['mail']);
     } elseif (isset($data['user']['email'])) {
         $this->set_param('mail', $data['user']['email']);
     }
     $this->set_param('id_item', (int) $query->url(0));
 }
Example #13
0
File: Add.php Project: 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]);
 }
Example #14
0
 protected function get_params(Query $query)
 {
     $this->set_param('query', $query->to_url_string());
     $parsed = $query->parsed();
     if (!empty($parsed['tag']['is'])) {
         $this->set_param('tags', implode(' ', $parsed['tag']['is']) . ' ');
     } else {
         $this->set_param('tags', '');
     }
     $this->set_param('groups', []);
     $this->set_param('have_groups', 0);
     $this->set_param('packs', []);
     $this->set_param('have_packs', 0);
     $this->set_param('manga', []);
     $this->set_param('have_manga', 0);
 }
Example #15
0
File: Admin.php Project: 4otaku/art
 protected function get_modules(Query $query)
 {
     if (!Session::getInstance()->is_moderator()) {
         return [];
     }
     $return = [new HtmlAdminMenu($query)];
     if ($query->url(1) == 'tag') {
         $return[] = new HtmlAdminTag($query);
     }
     if ($query->url(1) == 'help') {
         $return[] = new HtmlAdminHelp($query);
     }
     if ($query->url(1) == 'similar') {
         $return[] = new HtmlAdminSimilar($query);
     }
     return $return;
 }
Example #16
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);
 }
Example #17
0
File: Edit.php Project: 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);
 }
Example #18
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));
 }
Example #19
0
File: Save.php Project: 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]);
 }
Example #20
0
File: List.php Project: 4otaku/art
 protected function get_modules(Query $query)
 {
     $return = array('title' => new HtmlArtTitle($query), 'search' => new HtmlArtSearch($query), 'error' => new HtmlArtError($query, true), 'list' => new Container(__NAMESPACE__ . '\\HtmlThumbnail' . ucfirst($query->mode())), 'tags' => new HtmlSidebarTag($query), 'tags_pool' => new HtmlSidebarTag($query), 'editmenu' => new HtmlSidebarEditmenu($query), 'editfield' => new HtmlArtEditfield($query), 'tools' => new HtmlSidebarTool($query), 'recent_comments' => new HtmlSidebarComment($query), 'paginator' => new HtmlArtPaginator($query));
     if ($query->is_pool_list()) {
         $return['tags']->set_pool_mode($query->mode());
         $return['tags_pool']->disable();
         $return['editmenu']->disable();
     } elseif ($query->get_pool_mode()) {
         $return['tags_pool']->set_pool_mode($query->get_pool_mode());
         $this->pool_tag_request = ['api' => 'art_' . $query->get_pool_mode(), 'id' => $query->get_pool_value()];
     } else {
         $return['tags_pool']->disable();
     }
     return $return;
 }
Example #21
0
File: Tag.php Project: 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);
 }
Example #22
0
File: Art.php Project: 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);
 }
Example #23
0
File: List.php Project: 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');
     }
 }
Example #24
0
File: Body.php Project: 4otaku/art
 protected function get_modules(Query $query)
 {
     if (is_numeric($query->url(0))) {
         $this->title = 'Арт №' . $query->url(0);
         return new HtmlArtItem($query);
     }
     if ($query->url(0) == 'admin') {
         $this->title = 'Админка';
         return new HtmlAdmin($query);
     }
     if ($query->url(0) == 'add') {
         $this->title = 'Загрузка новых артов';
         return new HtmlAdd($query);
     }
     if ($query->url(0) == 'add_to') {
         return new HtmlCollect($query);
     }
     return new HtmlArtList($query);
 }
Example #25
0
File: Merge.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->id = $query->get('id');
     $this->set_param('id', $this->id);
 }
Example #26
0
File: Title.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $search = array();
     $other = $query->other();
     $parsed = $query->parsed(false);
     if ($query->get_pool_mode()) {
         $search[] = array($query->get_pool_mode() => $query->get_pool_value());
     } elseif ($query->mode() != 'art') {
         $search[] = array('mode' => $query->mode());
     } else {
         if (!empty($other['approved']) && $other['approved'] != 'yes') {
             $search[] = array('approved' => $other['approved']);
         }
         if (!empty($other['tagged']) && $other['tagged'] != 'yes') {
             $search[] = array('tagged' => $other['tagged']);
         }
     }
     foreach ($parsed as $key => $data) {
         if (!empty($data['is'])) {
             $search[] = array($key . '_is' => $data['is']);
         }
     }
     foreach ($parsed as $key => $data) {
         if (!empty($data['more'])) {
             $search[] = array($key . '_more' => $data['more']);
         }
     }
     foreach ($parsed as $key => $data) {
         if (!empty($data['less'])) {
             $search[] = array($key . '_less' => $data['less']);
         }
     }
     foreach ($parsed as $key => $data) {
         if (!empty($data['not'])) {
             $search[] = array($key . '_not' => $data['not']);
         }
     }
     $other['sort'] = empty($other['sort']) ? 'date' : $other['sort'];
     $other['order'] = empty($other['order']) ? 'desc' : $other['order'];
     if ($other['order'] != 'desc' || $other['sort'] != 'date') {
         $search[] = array('sort' => $other['sort']);
         if ($other['sort'] != 'none' && $other['sort'] != 'random') {
             $search[] = array('order' => $other['order']);
         }
     }
     $primary = true;
     foreach ($search as &$part) {
         $value = reset($part);
         $function = 'word_' . key($part);
         if (is_callable(array($this, $function))) {
             $part = $this->{$function}($value, $primary);
             if ($primary) {
                 $part = $this->primary_transform($part);
             }
             $primary = false;
         } else {
             $part = null;
         }
     }
     $this->search = array_filter($search);
     if ($this->request === null) {
         $this->set_param('query', implode(', ', $this->search));
     }
 }
Example #27
0
File: Rate.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->id = $query->get('id');
     $this->approve = $query->get('approve');
 }
Example #28
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());
 }
Example #29
0
File: Tag.php Project: 4otaku/art
 protected function get_params(Query $query)
 {
     $this->params = $query->get();
     unset($this->params['format']);
 }
Example #30
0
 protected function get_params(Query $query)
 {
     if ((int) $query->get('page')) {
         $this->page = (int) $query->get('page');
     }
 }