/** * @param $search_text * @param string $token * @param string $secret * @return mixed */ public function process_search($search_text, $token = '', $secret = '') { $url = $this->omero_api . "/ome_seadragon" . PathUtils::build_find_annotations_url($search_text); $content = $this->get($url, array(), $token, $secret); $data = json_decode($content); return $data; }
public static function findHereOrInParent($frag, $start, SystemLocals $locals = null) { if (!is_string($frag)) { throw new \InvalidArgumentException('Frag must be a string'); } if (!is_string($start)) { throw new \InvalidArgumentException('Start must be a string'); } if (empty($locals)) { $locals = new SystemLocals(); } $start = self::homeify($start, $locals); if (!file_exists($start)) { throw new \InvalidArgumentException('Start must be a valid path to a file or directory'); } if (!is_dir($start)) { $start = dirname($start); } $dir = PathUtils::untrailslashit($start); $frag = PathUtils::unleadslashit($frag); while (!file_exists($dir . DIRECTORY_SEPARATOR . $frag) && '/' !== $dir) { $dir = dirname($dir); } return $dir == '/' ? false : realpath($dir . DIRECTORY_SEPARATOR . $frag); }
/** * Prepare file reference information * * @param string $source * @return string file referece */ public function get_file_reference($source) { global $USER, $CFG; debugging("---> Calling 'get_file_reference: {$source}' <---"); $reference = new stdClass(); $reference->path = "/omero-image-repository/{$source}"; $reference->userid = $USER->id; $reference->username = fullname($USER); // $reference->access_key = get_user_preferences($this->setting . '_access_key', ''); // $reference->access_secret = get_user_preferences($this->setting . '_access_secret', ''); // by API we don't know if we need this reference to just download a file from omero // into moodle filepool or create a reference. Since we need to create a shared link // only in case of reference we analyze the script parameter $usefilereference = optional_param('usefilereference', false, PARAM_BOOL); if ($usefilereference) { debugging("Computing reference: {$usefilereference}"); $this->omero->set_access_token($reference->access_key, $reference->access_secret); $url = $this->omero->get_file_share_link($source, $CFG->repositorygetfiletimeout); if ($url) { unset($reference->access_key); unset($reference->access_secret); $reference->url = PathUtils::build_image_detail_url($source); debugging("Computed reference: " . $reference->url); } } return serialize($reference); }
/** * @test * it should find files with relative dirnname */ public function it_should_find_files_with_relative_dirnname() { $path = dirname(dirname(dirname(__FILE__))) . '/foo.php'; touch($path); $this->assertEquals($path, PathUtils::findHereOrInParent('../../foo.php', dirname(__FILE__))); unlink($path); }
// set the Moodle root directory $MOODLEROOT = dirname(dirname(dirname(dirname(dirname(__FILE__))))); // load dependencies require_once "{$MOODLEROOT}/config.php"; require_once "{$MOODLEROOT}/repository/omero/lib.php"; require_once "{$MOODLEROOT}/repository/omero/locallib.php"; // check whether Moodle Env exists defined('MOODLE_INTERNAL') || die; // check whether the user is logged if (!isloggedin()) { $moodle_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/moodle"; header('Location: ' . $moodle_url); } // omero server $omero_server = new omero(); // get method $method = required_param("m", PARAM_TEXT); // get the Image ID $image_id = required_param("id", PARAM_INT); // set the response header header('Content-Type: application/json'); if ($method == "img_details") { echo $omero_server->process_request(PathUtils::build_image_detail_url($image_id), false); } else { if ($method == "dzi") { echo $omero_server->process_request(PathUtils::build_image_dzi_url($image_id), false); } else { echo json_encode(array("error" => "Not supported method!!!")); } } exit;
function configure_call() { $js = array("error" => 0, "data" => array("RETURN_DATA_JSON" => 0, "RETURN_DATA_JSONP" => 1, "DATA_FORMAT" => OutputHelper::$return_data, "CALL_URL" => PathUtils::siteurl(), "SERVER_TYPE" => 'php_ajax', "CONEXION_HTTP" => 0, "CONEXION_WS" => 1, "CONEXION_TYPE" => 0, "BRACKS_DIR" => realpath(CURRENT_PAT . "/../../../adobe-brackets/src"))); $out = $this->output->json_unicode_encode($js); if (isset($_GET['callback'])) { $out = $_GET['callback'] . "({$out})"; } header("Content-Type: application/javascript"); die($out); }