示例#1
0
    public function action_search()
    {
        $search = array('any' => explode(' ', @$_POST['any']), 'artist' => explode(' ', @$_POST['artist']), 'title' => explode(' ', @$_POST['title']), 'desc' => explode(' ', @$_POST['desc']), 'series' => explode(' ', @$_POST['series']), 'tags' => explode(' ', @$_POST['tags']));
        $order_choices = array('date desc', 'date asc', 'title asc', 'title desc', 'id desc', 'id asc');
        $perpage = isset($_POST['perpage']) ? (int) $_POST['perpage'] : 20;
        $order = isset($_POST['order']) ? $_POST['order'] : 'date desc';
        $curpage = isset($_POST['curpage']) ? (int) $_POST['curpage'] : 1;
        if (isset($_POST['next'])) {
            $curpage++;
        } else {
            if (isset($_POST['prev'])) {
                $curpage--;
            }
        }
        if ($curpage < 1) {
            $curpage = 1;
        }
        ?>
		<form class="form-horizontal" method="post" role="form">
			<div class="form-group row">
				<?php 
        HH::print_form_field('Any', 'any', @$_POST['any']);
        ?>
			
				<?php 
        HH::print_form_field('Artist', 'artist', @$_POST['artist']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Title', 'title', @$_POST['title']);
        ?>
				
				<?php 
        HH::print_form_field('Desc', 'desc', @$_POST['desc']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Series', 'series', @$_POST['series']);
        ?>
			
				<?php 
        HH::print_form_field('Tags', 'tags', @$_POST['tags']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Items', 'perpage', $perpage, 3);
        ?>
				
				<?php 
        HH::print_form_field('Page', 'curpage', $curpage, 3);
        ?>
				
				<?php 
        HH::print_radio_field('Order', 'order', $order_choices, $order);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
			
	<?php 
        $q = Model::factory('Hmanga')->limit($perpage)->offset(($curpage - 1) * $perpage);
        foreach ($order_choices as $choice) {
            if ($order == $choice) {
                list($column, $direction) = explode(' ', $choice);
                if ($direction == 'desc') {
                    $q->order_by_desc($column);
                } else {
                    $q->order_by_asc($column);
                }
            }
        }
        // filter
        foreach ($search['title'] as $term) {
            if ($term) {
                $q->where_like('title', "%{$term}%");
            }
        }
        foreach ($search['series'] as $term) {
            if ($term) {
                $q->where_like('series', "%{$term}%");
            }
        }
        foreach ($search['artist'] as $term) {
            if ($term) {
                $q->where_like('artist', "%{$term}%");
            }
        }
        foreach ($search['desc'] as $term) {
            if ($term) {
                $q->where_like('desc', "%{$term}%");
            }
        }
        foreach ($search['tags'] as $term) {
            if ($term) {
                $q->where_like('tags', "%#{$term}#%");
            }
        }
        foreach ($search['any'] as $term) {
            if ($term) {
                $q->where_raw('(title LIKE ? OR series LIKE ? OR artist LIKE ? OR desc LIKE ? OR tags LIKE ?)', array("%{$term}%", "%{$term}%", "%{$term}%", "%{$term}%", "%{$term}%"));
            }
        }
        $result = $q->find_many();
        ?>
		<?php 
        foreach ($result as $i => $hmanga) {
            ?>
			<?php 
            $samples = $hmanga->samples();
            ?>
			<?php 
            if ($hmanga->is_deleted) {
                continue;
            }
            ?>

			<?php 
            if ($i % 2 == 0) {
                echo '<div class="row">';
            }
            ?>
			<div class="col-md-6 result">
				<a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
" title="<?php 
            echo $hmanga->desc;
            ?>
">
					<img src="<?php 
            echo $samples[0];
            ?>
" alt="th" width="100" height="140">
					<img src="<?php 
            echo $samples[1];
            ?>
" alt="th" width="100" height="140">
				</a>

				<dl class="dl-horizontal result">
					<dt>Title</dt><dd><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
"><?php 
            echo $hmanga->title;
            ?>
</a></dd>
					<dt>Series</dt><dd><?php 
            echo $hmanga->series;
            ?>
</dd>
					<dt>Artist</dt><dd><?php 
            echo $hmanga->artist;
            ?>
</dd>
					<dt>Date</dt><dd><?php 
            echo $hmanga->date;
            ?>
</dd>
					<dt>Page</dt><dd><?php 
            echo $hmanga->count();
            ?>
</dd>
					<dt>Tags</dt><dd><?php 
            echo str_replace('#', ' ', $hmanga->tags);
            ?>
</dd>
					<dt><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">VIEW</a></dt>
					<dd>
						<a href="<?php 
            echo Fakku::$base . $hmanga->url;
            ?>
">ORIGIN</a>
						<a href="<?php 
            echo HH::url("action=dump&id={$hmanga->id}");
            ?>
">DUMP</a>
					</dd>
				</dl>
			</div>
			<?php 
            if ($i % 2 == 1) {
                echo '</div>';
            }
            ?>
		<?php 
        }
        ?>
		
		<div class="form-group" style="display:block;clear:both">
			<?php 
        HH::print_submit_buttons();
        ?>
		</div>
	</form>
	<?php 
    }
    public function action_search()
    {
        $order_choices = array('date desc', 'date asc', 'title asc', 'title desc', 'id desc', 'id asc', 'pages asc', 'pages desc');
        $order = isset($_POST['order']) ? $_POST['order'] : 'date desc';
        $perpage = isset($_POST['perpage']) ? (int) $_POST['perpage'] : 20;
        $curpage = isset($_POST['curpage']) ? (int) $_POST['curpage'] : 1;
        if (isset($_POST['next'])) {
            $curpage++;
        } else {
            if (isset($_POST['prev'])) {
                $curpage--;
            }
        }
        if ($curpage < 1) {
            $curpage = 1;
        }
        $result = $this->search($perpage, $curpage, $order, @$_POST['any'], @$_POST['title']);
        ?>
		<form class="form-horizontal" method="post">
			<div class="form-group row">
				<?php 
        HH::print_form_field('Any', 'any', @$_POST['any']);
        ?>
			
				<?php 
        HH::print_form_field('Title', 'title', @$_POST['title']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Items', 'perpage', $perpage, 3);
        ?>
				
				<?php 
        HH::print_form_field('Page', 'curpage', $curpage, 3);
        ?>
				
				<?php 
        HH::print_radio_field('Order', 'order', $order_choices, $order);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
		
			<?php 
        foreach ($result as $i => $hmanga) {
            ?>
				<?php 
            if ($i % 2 == 0) {
                echo '<div class="row">';
            }
            ?>
				<div class="col-md-6 result">
					<?php 
            echo "{$hmanga->title} | {$hmanga->pages} pages | {$hmanga->date}";
            ?>
					<a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">VIEW</a>
					<a href="<?php 
            echo self::$base . $hmanga->url;
            ?>
">ORIGIN</a>
					<br>
					<?php 
            $samples = $hmanga->samples();
            ?>
					<a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
" title="<?php 
            echo $hmanga->description;
            ?>
">
						<?php 
            foreach ($samples as $img) {
                ?>
							<img src="<?php 
                echo $img;
                ?>
" alt="th" width="145" height="232">
						<?php 
            }
            ?>
					</a>
					<?php 
            echo str_replace('#', ', ', trim($hmanga->tags, '#'));
            ?>
				</div>
				<?php 
            if ($i % 2 == 1) {
                echo '</div>';
            }
            ?>
			<?php 
        }
        ?>

			<div class="form-group row" style="display:block;clear:both">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
		</form>
		<?php 
    }
示例#3
0
    public function action_search()
    {
        $order = isset($_POST['order']) ? $_POST['order'] : 'date desc';
        $perpage = isset($_POST['perpage']) ? (int) $_POST['perpage'] : 20;
        $curpage = isset($_POST['curpage']) ? (int) $_POST['curpage'] : 1;
        if (isset($_POST['next'])) {
            $curpage++;
        } else {
            if (isset($_POST['prev'])) {
                $curpage--;
            }
        }
        if ($curpage < 1) {
            $curpage = 1;
        }
        // ORM::configure('logging', true);
        $result = $this->search($perpage, $curpage, $order, @$_POST['any'], @$_POST['title']);
        // echo ORM::get_last_query();
        ?>
		<form class="form-horizontal" method="post" role="form">
			<div class="form-group row">
				<?php 
        HH::print_form_field('Any', 'any', @$_POST['any']);
        ?>
			
				<?php 
        HH::print_form_field('Title', 'title', @$_POST['title']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Items', 'perpage', $perpage, 3);
        ?>
				
				<?php 
        HH::print_form_field('Page', 'curpage', $curpage, 3);
        ?>
				
				<?php 
        HH::print_radio_field('Order', 'order', $this->get_order_choices(), $order);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>

			<?php 
        foreach ($result as $i => $book) {
            ?>
				<?php 
            if ($i % 2 == 0) {
                echo '<div class="row">';
            }
            ?>
				<?php 
            $this->print_book($book);
            ?>
				<?php 
            if ($i % 2 == 1) {
                echo '</div>';
            }
            ?>
			<?php 
        }
        ?>

			<div class="form-group" style="display:block;clear:both">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
		</form>

		<?php 
    }
示例#4
0
    public function action_search()
    {
        $search = array('any' => explode(' ', @$_REQUEST['any']), 'title' => explode(' ', @$_REQUEST['title']), 'artist' => explode(' ', @$_REQUEST['artist']), 'origin' => explode(' ', @$_REQUEST['origin']), 'tags' => explode(' ', @$_REQUEST['tags']), 'include' => @$_REQUEST['include'], 'exclude' => @$_REQUEST['exclude']);
        $order_choices = array('added desc', 'added asc', 'title asc', 'title desc', 'id desc', 'id asc', 'length asc', 'length desc');
        $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'added desc';
        $perpage = isset($_REQUEST['perpage']) ? $_REQUEST['perpage'] : 20;
        $curpage = isset($_REQUEST['curpage']) ? $_REQUEST['curpage'] : 1;
        if (isset($_REQUEST['next'])) {
            $curpage++;
        } else {
            if (isset($_REQUEST['prev'])) {
                $curpage--;
            }
        }
        if ($curpage < 1) {
            $curpage = 1;
        }
        ?>
		<form method="post" class="form-horizontal">
			<div class="form-group row">
				<?php 
        HH::print_form_field('Any', 'any', @$_REQUEST['any']);
        ?>
			
				<?php 
        HH::print_form_field('Title', 'title', @$_REQUEST['title']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Artist', 'artist', @$_REQUEST['artist']);
        ?>

				<?php 
        HH::print_form_field('Origin', 'origin', @$_REQUEST['origin']);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_form_field('Items', 'perpage', $perpage, 3);
        ?>
				
				<?php 
        HH::print_form_field('Page', 'curpage', $curpage, 3);
        ?>
				
				<?php 
        HH::print_radio_field('Order', 'order', $order_choices, $order);
        ?>
			</div>
			<div class="form-group row">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>
	<?php 
        $q = Model::factory('Hmanga')->limit($perpage)->offset(($curpage - 1) * $perpage);
        foreach ($order_choices as $choice) {
            if ($order == $choice) {
                list($column, $direction) = explode(' ', $choice);
                if ($direction == 'desc') {
                    $q->order_by_desc($column);
                } else {
                    $q->order_by_asc($column);
                }
            }
        }
        // filter
        foreach ($search['title'] as $term) {
            if ($term) {
                $q->where_like('title', "%{$term}%");
            }
        }
        foreach ($search['origin'] as $term) {
            if ($term) {
                $q->where_like('origin', "%{$term}%");
            }
        }
        foreach ($search['artist'] as $term) {
            if ($term) {
                $q->where_like('artist', "%{$term}%");
            }
        }
        foreach ($search['any'] as $term) {
            if ($term) {
                $q->where_raw('(title LIKE ? OR origin LIKE ? OR artist LIKE ?)', array("%{$term}%", "%{$term}%", "%{$term}%"));
            }
        }
        if (@$_REQUEST['include']) {
            foreach ($_REQUEST['include'] as $key => $vals) {
                foreach ($vals as $val) {
                    $q->where_like($key, "%#{$val}#%");
                }
            }
        }
        if (@$_REQUEST['exclude']) {
            foreach ($_REQUEST['exclude'] as $key => $vals) {
                foreach ($vals as $val) {
                    $q->where_not_like($key, "%#{$val}#%");
                }
            }
        }
        $result = $q->find_many();
        $ref = $this->get_ref();
        ?>
			<?php 
        foreach ($result as $i => $hmanga) {
            ?>
				<?php 
            if ($i % 2 == 0) {
                echo '<div class="row">';
            }
            ?>
				<div class="col-md-6 result">
					<?php 
            $samples = $hmanga->samples();
            ?>
					<a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">
						<img src="<?php 
            echo $samples[0];
            ?>
" alt="th">
						<img src="<?php 
            echo $samples[1];
            ?>
" alt="th">
					</a>

					<dl class="dl-horizontal result">
						<dt>Title</dt><dd><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
"><?php 
            echo $hmanga->title;
            ?>
</a></dd>
						<dt>Origin</dt><dd><?php 
            echo $hmanga->origin;
            ?>
</dd>
						<dt>Artist</dt><dd><?php 
            echo $hmanga->artist;
            ?>
</dd>
						<dt>Date</dt><dd><?php 
            echo $hmanga->added;
            ?>
</dd>
						<dt>Page</dt><dd><?php 
            echo $hmanga->length;
            ?>
</dd>
						<dt>Tags</dt><dd><?php 
            echo str_replace('#', ' ', $hmanga->type);
            ?>
</dd>
						<dt><a href="<?php 
            echo HH::url($this, "action=view&id={$hmanga->id}");
            ?>
">VIEW</a></dt>
						<dd><a href="<?php 
            echo $hmanga->link;
            ?>
">ORIGIN</a></dd>
					</dl>
				</div>
				<?php 
            if ($i % 2 == 1) {
                echo '</div>';
            }
            ?>
			<?php 
        }
        ?>
			
			<div class="form-group row" style="display:block;clear:both">
				<?php 
        HH::print_submit_buttons();
        ?>
			</div>

			<table border="2">
				<tr valign="top">
				<?php 
        $i = 0;
        ?>
				<?php 
        foreach ($ref as $key => $vals) {
            $i++;
            ?>
					<td>
					<table>
						<tr>
							<th><?php 
            echo $key;
            ?>
</th>
							<th>V</th>
							<th>X</th>
						</tr>
						<?php 
            foreach ($vals as $val) {
                ?>
							<tr>
								<td><?php 
                echo $val;
                ?>
</td>
								<td><input type="checkbox" name="include[<?php 
                echo $key;
                ?>
][]" value="<?php 
                echo $val;
                ?>
" <?php 
                if (in_array($val, (array) @$_REQUEST['include'][$key])) {
                    echo 'checked';
                }
                ?>
/></td>
								<td><input type="checkbox" name="exclude[<?php 
                echo $key;
                ?>
][]" value="<?php 
                echo $val;
                ?>
" <?php 
                if (in_array($val, (array) @$_REQUEST['exclude'][$key])) {
                    echo 'checked';
                }
                ?>
/></td>
							</tr>
						<?php 
            }
            ?>
					</table>
					</td>
					<?php 
            if ($i % 6 == 0) {
                ?>
				</tr>
				<tr valign="top">
					<?php 
            }
            ?>
				<?php 
        }
        ?>
				</tr>
			</table>
			<input type="submit" value="search" />
		</form>
		<?php 
    }