viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]
Filename | |
---|---|
src/library/VersionManager.php | |
src/views/SearchView.php | |
src/views/elements/SubsearchElement.php | |
src/views/helpers/ImagesHelper.php | |
tests/VersionManagerTest.php |
diff --git a/src/library/VersionManager.php b/src/library/VersionManager.php index e4dbfbb80..bce81518d 100644 --- a/src/library/VersionManager.php +++ b/src/library/VersionManager.php @@ -132,6 +132,8 @@ class VersionManager * @param bool $lock whether or not a lock should be obtained before * carrying out the operation * @param array $force_update_list + * @return mixed either an error code or the name of the hash_file in + * the repository for the version just created */ public function createVersion($file_changed = "", $folder = "", $now = 0, $lock = true, $force_update_list = []) @@ -222,9 +224,12 @@ class VersionManager return $hash_folder_name; } /** + * Read from the head version of the repository the contents of $file. + * * @param string $file name of file to get contents of * @param bool $lock whether or not a lock should be obtained before * carrying out the operation + * @return int success code */ public function headGetContents($file, $lock = true) { @@ -238,9 +243,13 @@ class VersionManager return file_get_contents($file); } /** + * Write $data into the file $file in the head version of the repository + * * @param string $file name of file to store data for + * @param string $data what to store in the file $file * @param bool $lock whether or not a lock should be obtained before * carrying out the operation + * @return int success code */ public function headPutContents($file, $data, $lock = true) { @@ -268,10 +277,14 @@ class VersionManager return self::SUCCESS; } /** + * Copies the data in a file $from_name in the head version of the + * repository to a different file named $to_name + * * @param string $from_name name of file or dir to copy * @param string $to_name name of file or dir to save copy to * @param bool $lock whether or not a lock should be obtained before * carrying out the operation + * @return int success code */ public function headCopy($from_name, $to_name, $lock = true) { @@ -298,9 +311,12 @@ class VersionManager return self::SUCCESS; } /** + * Deletes a file $file from the head version of the repository + * * @param string $file name of file to delete * @param bool $lock whether or not a lock should be obtained before * carrying out the operation + * @return int success code */ public function headDelete($file, $lock = true) { @@ -330,9 +346,13 @@ class VersionManager return self::SUCCESS; } /** + * Makes a directory named $dir in the current folder in the head + * version of the repository being managed + * * @param string $dir name of directory folder to make * @param bool $lock whether or not a lock should be obtained before * carrying out the operation + * @return int success code */ public function headMakeDirectory($dir, $lock = true) { @@ -354,10 +374,14 @@ class VersionManager return self::SUCCESS; } /** + * Renames the file $old_name in the head version of the + * repository to a different file named $new_name + * * @param string $old_name original name of file * @param string $new_name what to change it to * @param bool $lock whether or not a lock should be obtained before * carrying out the operation + * @return int success code */ public function headRename($old_name, $new_name, $lock = true) { @@ -431,6 +455,8 @@ class VersionManager } } /** + * + * * @param int $timestamp of version what to restore to * @param bool $lock whether or not a lock should be obtained before * carrying out the operation diff --git a/src/views/SearchView.php b/src/views/SearchView.php index c44e18b53..b1c10d26d 100755 --- a/src/views/SearchView.php +++ b/src/views/SearchView.php @@ -277,13 +277,19 @@ class SearchView extends View implements CrawlConstants } ?><div class='result'> <?php + if (in_array("images", $data["SUBSEARCHES"])) { + $image_subsearch = true; + } else { + $image_subsearch = false; + } $subsearch = (isset($data["SUBSEARCH"])) ? $data["SUBSEARCH"] : ""; $base_query = "?".$token_string_amp. "c=search"; if (isset($page['IMAGES'])) { $this->helper("images")->render($page['IMAGES'], - $base_query."&q={$data['QUERY']}", $subsearch); + $base_query."&q={$data['QUERY']}", $subsearch, + $image_subsearch); e( "</div>"); continue; } else if (isset($page['NEWS'])) { diff --git a/src/views/elements/SubsearchElement.php b/src/views/elements/SubsearchElement.php index d85698dec..c26b21fd8 100644 --- a/src/views/elements/SubsearchElement.php +++ b/src/views/elements/SubsearchElement.php @@ -75,7 +75,8 @@ class SubsearchElement extends Element if ($subsearch['FOLDER_NAME'] == $data['SUBSEARCH']) { e(" [<b>". - $subsearch['SUBSEARCH_NAME']."</b>]"); + $subsearch['SUBSEARCH_NAME'] . + "</b>]"); break; } } diff --git a/src/views/helpers/ImagesHelper.php b/src/views/helpers/ImagesHelper.php index b13f114a8..dab8acbcb 100644 --- a/src/views/helpers/ImagesHelper.php +++ b/src/views/helpers/ImagesHelper.php @@ -48,15 +48,24 @@ class ImagesHelper extends Helper implements CrawlConstants * @param array $image_pages page data and thumbnails for images * @param string $query the current search query * @param string $subsearch name of subsearch page this image group on + * @param bool $image_subsearch whether the image subsearch is + * enabled on this Yioop instance */ - public function render($image_pages, $query, $subsearch) + public function render($image_pages, $query, $subsearch, + $image_subsearch = true) { - if ($subsearch != 'images') {?> - <h2><a href="<?= $query.'&s=images' ?>" + if ($subsearch != 'images') { + if ($image_subsearch) { + $query .= '&s=images'; + } else { + $query .= '%20media:images'; + } + ?> + <h2><a href="<?= $query ?>" ><?=tl('images_helper_view_image_results') ?></a></h2> - <?php - }?> - <div class="image-list"> + <?php + } + ?><div class="image-list"> <?php $i = 0; $break_frequency = 5; @@ -70,10 +79,10 @@ class ImagesHelper extends Helper implements CrawlConstants } else { $link = htmlentities($page[self::URL]); } - ?> + ?> <a href="<?= $link ?>" rel="nofollow"><img src="<?= - $page[self::THUMB] ?>" alt="<?= $page[self::TITLE] ?>" /></a> - <?php + $page[self::THUMB] ?>" alt="<?= $page[self::TITLE] ?>" /> + </a><?php $i++; if ($i % $break_frequency == 0) { e('<br />'); diff --git a/tests/VersionManagerTest.php b/tests/VersionManagerTest.php index 67b4f0790..e5959f26a 100644 --- a/tests/VersionManagerTest.php +++ b/tests/VersionManagerTest.php @@ -137,7 +137,8 @@ class VersionManagerTest extends UnitTest } } /** - * + * Tests file manipulations that can be done on files in the head version + * of the repository. (copy a file, rename a file, delete a file). */ public function copyDeleteRenameTestCase() {