本文整理汇总了PHP中Part::get_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::get_name方法的具体用法?PHP Part::get_name怎么用?PHP Part::get_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::get_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* @brief Create a new device-part
*
* @param Database &$database reference to the database object
* @param User &$current_user reference to the current user which is logged in
* @param Log &$log reference to the Log-object
* @param integer $device_id the ID of the device
* @param integer $part_id the ID of the part
* @param integer $quantity the mount quantity (see DevicePart::set_mount_quantity())
* @param string $mountnames the mountname(s) (see DevicePart::set_mount_name())
* @param boolean $increase_if_exist @li if true, and there is already a DevicePart with the same
* part ID + device ID, the mount quantity of the existing
* DevicePart will be incremented by $quantity. In addition,
* the new mount name ($mountname) will be attached (with a
* comma) at the end of the mount name of the existing DevicePart.
* @li if false, and there is already a DevicePart with the same
* part ID + device ID, this method will throw an exception.
*
* @retval DevicePart the new device-part
* @retval DevicePart the existing device-part, if there is already a DevicePart with
* the same part ID + device ID and "$increment_if_exist == true"
*
* @throws Exception if (this combination of) values is not valid
* @throws Exception if there was an error
*
* @see DBElement::add()
*/
public static function add(&$database, &$current_user, &$log, $device_id, $part_id, $quantity, $mountnames = '', $increase_if_exist = false)
{
$existing_devicepart = DevicePart::get_device_part($database, $current_user, $log, $device_id, $part_id);
if (is_object($existing_devicepart)) {
if ($increase_if_exist) {
if (!is_int($quantity) && !ctype_digit($quantity) || $quantity < 0) {
debug('error', 'quantity = "' . $quantity . '"', __FILE__, __LINE__, __METHOD__);
throw new Exception('Die Bestückungs-Anzahl ist ungültig!');
}
$quantity = $existing_devicepart->get_mount_quantity() + $quantity;
$old_mountnames = $existing_devicepart->get_mount_names();
if (strlen($mountnames) > 0) {
if (strlen($old_mountnames) > 0) {
$mountnames = $old_mountnames . ', ' . $mountnames;
}
} else {
$mountnames = $old_mountnames;
}
$existing_devicepart->set_attributes(array('quantity' => $quantity, 'mountnames' => $mountnames));
return $existing_devicepart;
} else {
$device = new Device($database, $current_user, $log, $device_id);
$part = new Part($database, $current_user, $log, $part_id);
throw new Exception('Die Baugruppe "' . $device->get_name() . '" enthält bereits das Bauteil "' . $part->get_name() . '"!');
}
}
// there is no such DevicePart, so we will create it
return parent::add($database, $current_user, $log, 'device_parts', array('id_device' => $device_id, 'id_part' => $part_id, 'quantity' => $quantity, 'mountnames' => $mountnames));
}
示例2: strcasecmp
/**
* @brief Compare function for "usort()"
*
* From php.net: The comparison function must return an integer less than,
* equal to, or greater than zero if the first argument is considered
* to be respectively less than, equal to, or greater than the second.
*
* @param Part $part_1 The Part Object #1
* @param Part $part_2 The Part Object #2
*
* @retval integer
*/
static function usort_compare($part_1, $part_2)
{
if ($part_1->get_name() != $part_2->get_name()) {
return strcasecmp($part_1->get_name(), $part_2->get_name());
} else {
// names are identical, so we compare the description of the parts
return strcasecmp($part_1->get_description(), $part_2->get_description());
}
}
示例3:
}
/********************************************************************************
*
* Set the rest of the HTML variables
*
*********************************************************************************/
$html->use_javascript(array('validatenumber', 'popup'));
// global settings
$html->set_variable('use_modal_popup', $config['popup']['modal'], 'boolean');
$html->set_variable('popup_width', $config['popup']['width'], 'integer');
$html->set_variable('popup_height', $config['popup']['height'], 'integer');
if (!$fatal_error) {
try {
// part attributes
$html->set_variable('pid', $part->get_id(), 'integer');
$html->set_variable('name', $part->get_name(), 'string');
$html->set_variable('manufacturer_product_url', $part->get_manufacturer_product_url(), 'string');
$html->set_variable('description', $part->get_description(), 'string');
$html->set_variable('category_full_path', $part->get_category()->get_full_path(), 'string');
$html->set_variable('instock', $part->get_instock(), 'integer');
$html->set_variable('mininstock', $part->get_mininstock(), 'integer');
$html->set_variable('visible', $part->get_visible(), 'boolean');
$html->set_variable('comment', nl2br($part->get_comment()), 'string');
$html->set_variable('footprint_full_path', is_object($footprint) ? $footprint->get_full_path() : '-', 'string');
$html->set_variable('footprint_filename', is_object($footprint) ? str_replace(BASE, BASE_RELATIVE, $footprint->get_filename()) : '', 'string');
$html->set_variable('storelocation_full_path', is_object($storelocation) ? $storelocation->get_full_path() : '-', 'string');
$html->set_variable('storelocation_is_full', is_object($storelocation) ? $storelocation->get_is_full() : false, 'boolean');
$html->set_variable('manufacturer_full_path', is_object($manufacturer) ? $manufacturer->get_full_path() : '-', 'string');
$html->set_variable('category_full_path', is_object($category) ? $category->get_full_path() : '-', 'string');
$html->set_variable('auto_order_exists', $part->get_instock() < $part->get_mininstock(), 'boolean');
$html->set_variable('manual_order_exists', $part->get_manual_order() && $part->get_instock() >= $part->get_mininstock(), 'boolean');