本文整理汇总了PHP中Part::search_parts方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::search_parts方法的具体用法?PHP Part::search_parts怎么用?PHP Part::search_parts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::search_parts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
if ($search_footprint) {
$header .= '&search_footprint=1';
}
if ($search_manufacturer) {
$header .= '&search_manufacturer=1';
}
header($header);
}
/********************************************************************************
*
* Generate Table
*
*********************************************************************************/
if (!$fatal_error) {
try {
$category_parts = Part::search_parts($database, $current_user, $log, $keyword, 'categories', $search_name, $search_description, $search_comment, $search_footprint, $search_category, $search_storelocation, $search_supplier, $search_supplierpartnr, $search_manufacturer);
$hits_count = count($category_parts, COUNT_RECURSIVE) - count($category_parts);
$parts_table_loops = array();
foreach ($category_parts as $category_full_path => $parts) {
$parts_table_loops[$category_full_path] = Part::build_template_table_array($parts, 'search_parts');
}
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
$fatal_error = true;
}
}
/********************************************************************************
*
* Set the rest of the HTML variables
*
*********************************************************************************/
示例2: catch
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
$fatal_error = true;
}
/********************************************************************************
*
* Execute actions
*
*********************************************************************************/
if (!$fatal_error) {
switch ($action) {
case 'show_searched_parts':
// show the search results for adding parts to this device
try {
// search parts by name and description
$searched_parts = Part::search_parts($database, $current_user, $log, $new_part_name, '', true, true, false, false, false, false, false, false);
$searched_parts_loop = Part::build_template_table_array($searched_parts, 'searched_device_parts');
$html->set_variable('searched_parts_rowcount', count($searched_parts), 'integer');
$html->set_variable('no_searched_parts_found', count($searched_parts) == 0, 'integer');
} catch (Exception $e) {
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
}
break;
case 'assign_by_selected':
// add some parts (which were listed by part search) to this device
for ($i = 0; $i < $searched_parts_rowcount; $i++) {
$part_id = isset($_REQUEST['id_' . $i]) ? (int) $_REQUEST['id_' . $i] : 0;
$quantity = isset($_REQUEST['quantity_' . $i]) ? abs((int) $_REQUEST['quantity_' . $i]) : 0;
$mountname = isset($_REQUEST['mountnames_' . $i]) ? trim((string) $_REQUEST['mountnames_' . $i]) : '';
if ($quantity > 0) {
try {
示例3: match_devicepart_names_to_ids
/**
* @brief Fill in DevicePart IDs of an associative array (from "import_text_to_array()") where only the part names are used (instead of the IDs)
*
* If the user has used part names ("devicepart_part_name") instead of part IDs ("devicepart_part_id"),
* this funtion will search for these parts and fill in the IDs in "devicepart_part_id".
*
* If no unique part is found, this function will ignore this device part ("devicepart_part_id == 0").
* After trying to import such parts, you will get an exception.
*
* @note You should ALWAYS call this function after using "import_text_to_array()" with device parts!
* But it's not necessary to call it after building the data array with "extract_import_data_from_request()".
*
* @param Database &$database reference to the database object
* @param User &$current_user reference to the user which is logged in
* @param Log &$log reference to the Log-object
* @param array &$data reference to the data array from the function "import_text_to_array()"
*
* @throws Exception if there was an error (but NOT if the search for parts was not successful)
*/
function match_devicepart_names_to_ids(&$database, &$current_user, &$log, &$data)
{
foreach ($data as $key => $row) {
if ($row['devicepart_part_id'] <= 0 && strlen($row['devicepart_part_name']) > 0) {
// we have only the name of the part, not the ID
// --> try to find the ID by the name
$parts = Part::search_parts($database, $current_user, $log, $row['devicepart_part_name'], '', true, false);
foreach ($parts as $partkey => $part) {
if ($part->get_name() != $row['devicepart_part_name']) {
unset($parts[$partkey]);
}
}
if (count($parts) == 1) {
$data[$key]['devicepart_part_id'] = $parts[0]->get_id();
}
}
}
}