示例#1
0
 public function render($bEcho = true)
 {
     $str = '';
     if ($this->page) {
         $str .= "<table><tr><th>Product Name</th>";
         $displayedElements = App::Get()->settings['browser_products_met'];
         foreach ($displayedElements as $elementName) {
             $str .= "<th>{$elementName}</th>";
         }
         $str .= "</tr>";
         if (!App::Get()->settings['browser_private_products_visibility']) {
             // Get a CAS-Browser XML/RPC client
             $browser = new CasBrowser();
             $client = $browser->getClient();
             foreach ($this->pageMetadata as $key => $value) {
                 if ($browser->getProductVisibilityLevel($key) == "deny") {
                     unset($this->pageMetadata[$key]);
                     foreach ($this->pageProducts as $product) {
                         if ($product->id == $key) {
                             $productKey = array_search($product, $this->pageProducts);
                             unset($this->pageProducts[$productKey]);
                         }
                     }
                 }
             }
         }
         foreach ($this->pageProducts as $product) {
             $str .= "<tr><td><a href=\"" . $this->urlBase . "/product/{$product->getId()}/{$this->returnPage}\">" . urlDecode(basename($product->getName())) . "</a></td>";
             foreach ($displayedElements as $elementName) {
                 $str .= "<td>" . $this->pageMetadata[$product->getId()]->getMetadata($elementName) . "</td>";
             }
             $str .= "</tr>";
         }
         $str .= "</table>";
     }
     if ($bEcho) {
         echo $str;
     } else {
         return $str;
     }
 }
示例#2
0
文件: product.php 项目: fornava/oodt
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$module = App::Get()->loadModule();
require_once $module->modulePath . "/classes/CasBrowser.class.php";
require_once $module->modulePath . "/scripts/widgets/MetadataDisplayWidget.php";
require_once $module->modulePath . "/scripts/widgets/ProductDownloadWidget.php";
// Get a CAS-Browser XML/RPC client
$browser = new CasBrowser();
$client = $browser->getClient();
// Get the specified product
$productId = App::Get()->request->segments[0];
$product = $client->getProductById($productId);
$productName = $product->getName();
$productTypeName = $product->getType()->getName();
$productTypeId = $product->getType()->getId();
$productMetadata = $client->getMetadata($product);
// Get metadata for product and productType as associative arrays
$productTypeInfo = $product->getType()->toAssocArray();
$productInfo = $productMetadata->toAssocArray();
$productVisibilityLevel = $browser->getProductVisibilityLevel($productId);
// Redirect the user if they are not authorized
if ($productVisibilityLevel == CasBrowser::VIS_NONE) {
    App::Get()->redirect(SITE_ROOT . '/errors/403');
示例#3
0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$module = App::Get()->loadModule();
require_once $module->modulePath . "/classes/CasBrowser.class.php";
require_once $module->modulePath . "/scripts/widgets/CrossTypeSearchWidget.php";
// Get a CAS-Browser XML/RPC client
$browser = new CasBrowser();
$client = $browser->getClient();
// Initialize the CrossTypeSearchWidget
$querySiteRoot = isset(App::Get()->settings['query_service_url']) ? App::Get()->settings['query_service_url'] : 'http://' . $_SERVER['HTTP_HOST'] . $module->moduleRoot;
$crossTypeWidget = new CrossTypeSearchWidget(array('htmlID' => 'cas_browser_product_list', 'loadingID' => 'loading_icon_container', 'siteUrl' => $querySiteRoot));
$crossTypeWidget->renderScript();
// Store any filter and exclusive/inclusive parameters passed in via URL
$urlParams = CrossTypeSearchWidget::parseSegments();
$queryBoolValue = 'and';
$exclusiveChecked = true;
if (isset($urlParams['filterParams'])) {
    $filterButtonValue = "Hide Filters";
} else {
    $filterButtonValue = "Show Filters";
}
if (isset($urlParams['exclusive'])) {
示例#4
0
 * limitations under the License.
 */
$module = App::Get()->loadModule();
require_once dirname(dirname(__FILE__)) . '/classes/CasBrowser.class.php';
// Extract desired output format from POST
if (isset($_POST['OutputFormat'])) {
    try {
        $outputFormat = Utils::getRequestedReturnType($_POST['OutputFormat']);
    } catch (Exception $e) {
        Utils::reportError($e->getMessage(), 'html');
    }
} else {
    $outputFormat = 'html';
}
// Get client handle
$cb = new CasBrowser();
$client = $cb->getClient();
// Extract ProductType from POST
if (!isset($_POST['Type'])) {
    Utils::reportError("POST does not contain 'Type' ProductType", $outputFormat);
}
$typeName = $_POST['Type'];
try {
    $allTypes = $client->getProductTypes();
    $allTypeNames = array_map(create_function('$t', 'return $t->getName();'), $allTypes);
    if (!in_array($typeName, $allTypeNames)) {
        $errStr = "The type " . $typeName . " is not used in the repository.  Please use one of: ";
        for ($i = 0; $i < count($allTypeNames) - 1; $i++) {
            $errStr .= $allTypeNames[i] . ", ";
        }
        $errStr .= $allTypeNames[count($allTypeNames) - 1];
示例#5
0
文件: products.php 项目: fornava/oodt
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$module = App::Get()->loadModule();
require_once $module->modulePath . "/classes/CasBrowser.class.php";
require_once $module->modulePath . "/scripts/widgets/FilterWidget.php";
require_once $module->modulePath . "/scripts/widgets/ProductPageWidget.php";
// Get a CAS-Browser XML/RPC client
$browser = new CasBrowser();
$client = $browser->getClient();
// Get a  Product Type object
$productType = $client->getProductTypeById(App::Get()->request->segments[0]);
$ptID = $productType->getId();
$ptName = $productType->getName();
$typeInfo = $productType->toAssocArray();
// Determine the visibility level based on the current user
$ptVisibilityLevel = $browser->getProductTypeVisibilityLevel($ptID);
// Redirect the user if they are not authorized
if ($ptVisibilityLevel == CasBrowser::VIS_NONE) {
    App::Get()->redirect(SITE_ROOT . '/errors/403');
}
// Store any filter parameters passed in via URL
$filterParams = array();
$segments = App::Get()->request->segments;
示例#6
0
文件: index.php 项目: fornava/oodt
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$module = App::Get()->loadModule();
require_once $module->modulePath . "/classes/CasBrowser.class.php";
require_once $module->modulePath . "/scripts/widgets/ProductTypeListWidget.php";
// Get a CAS-Browser XML/RPC client
$browser = new CasBrowser();
$client = $browser->getClient();
$isAlive = $client->isAlive();
if (!$isAlive) {
    App::Get()->SetMessage("Filemgr at " . $client->serverURL . " is down. Please start it.<br>", CAS_MSG_ERROR);
} else {
    // Get a list of the product types managed by this server
    $response = $client->getProductTypes();
    $productTypes = array();
    foreach ($response as $pt) {
        $ptArray = $pt->toAssocArray();
        $ptVisibility = $browser->getProductTypeVisibilityLevel($pt->getId());
        if ($ptVisibility == CasBrowser::VIS_NONE) {
            continue;
        }
        $merged = array("name" => array($ptArray[App::Get()->settings['browser_pt_name_key']], $client->getNumProducts($pt)), "description" => array($ptArray[App::Get()->settings['browser_pt_desc_key']]), "id" => array($ptArray[App::Get()->settings['browser_pt_id_key']]));
示例#7
0
文件: dataset.php 项目: fornava/oodt
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Load the module context for this module
$module = App::Get()->loadModule();
require_once $module->modulePath . "/classes/CasBrowser.class.php";
require_once $module->modulePath . "/scripts/widgets/MetadataDisplayWidget.php";
// Get a CAS-Browser XML/RPC client
$browser = new CasBrowser();
$client = $browser->getClient();
// Get a  Product Type object
$productType = $client->getProductTypeById(App::Get()->request->segments[0]);
$ptID = $productType->getId();
$ptName = $productType->getName();
// Determine the visibility level based on the current user
$ptVisibilityLevel = $browser->getProductTypeVisibilityLevel($ptID);
// Redirect the user if they are not authorized
if ($ptVisibilityLevel == CasBrowser::VIS_NONE) {
    App::Get()->redirect(SITE_ROOT . '/errors/403');
}
// Load a MetadataDisplayWidget with the visible metadata for this product type
$typeMetadataWidget = new MetadataDisplayWidget(array());
$typeMetadataWidget->loadMetadata($browser->getVisibleMetadataForProductType($ptID));
// Create a MetadataDisplayWidget to display system metadata (all except typeMetadata)
示例#8
0
 public static function formatResults($products)
 {
     $cb = new CasBrowser();
     $client = $cb->getClient();
     $results = array();
     foreach ($products as $product) {
         try {
             $p = array('id' => $product['product']->getId(), 'name' => urlDecode($product['product']->getName()), 'metadata' => $client->getMetadata($product['product'])->toAssocArray());
             if (isset($product['typeName'])) {
                 $p['type'] = $product['typeName'];
             }
             array_push($results, $p);
         } catch (Exception $e) {
             throw new CasBrowserException("An error occured while formatting product [" . $product['product']->getId() . "] metadata: " . $e->getMessage());
         }
     }
     return $results;
 }