本文整理汇总了PHP中Printer::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::get方法的具体用法?PHP Printer::get怎么用?PHP Printer::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_post
public function add_post()
{
// Hook
$this->HookManager->processEvent('PRINTER_ADD_POST');
// POST
if ($_REQUEST['add'] != 1) {
$this->FOGCore->setMessage('Printer type changed to: ' . $_REQUEST['printertype']);
$this->FOGCore->redirect($this->formAction . '&printertype=' . $_REQUEST['printertype']);
}
if ($_REQUEST['add'] == 1) {
//Remove spaces from beginning and end offields needed.
$_REQUEST['alias'] = trim($_REQUEST['alias']);
$_REQUEST['port'] = trim($_REQUEST['port']);
$_REQUEST['inf'] = trim($_REQUEST['inf']);
$_REQUEST['model'] = trim($_REQUEST['model']);
$_REQUEST['ip'] = trim($_REQUEST['ip']);
try {
// PrinterManager
$PrinterManager = $this->getClass('PrinterManager');
// Error checking
if ($_REQUEST['printertype'] == "Local") {
if (empty($_REQUEST['alias']) || empty($_REQUEST['port']) || empty($_REQUEST['inf']) || empty($_REQUEST['model'])) {
throw new Exception('You must specify the alias, port, model, and inf. Unable to create!');
} else {
// Create new Object
$Printer = new Printer(array('name' => $_REQUEST['alias'], 'config' => $_REQUEST['printertype'], 'model' => $_REQUEST['model'], 'file' => $_REQUEST['inf'], 'port' => $_REQUEST['port'], 'ip' => $_REQUEST['ip']));
}
}
if ($_REQUEST['printertype'] == "iPrint") {
if (empty($_REQUEST['alias']) || empty($_REQUEST['port'])) {
throw new Exception('You must specify the alias and port. Unable to create!');
} else {
// Create new Object
$Printer = new Printer(array('name' => $_REQUEST['alias'], 'config' => $_REQUEST['printertype'], 'port' => $_REQUEST['port']));
}
}
if ($_REQUEST['printertype'] == "Network") {
if (empty($_REQUEST['alias'])) {
throw new Exception('You must specify the alias. Unable to create!');
} else {
// Create new Object
$Printer = new Printer(array('name' => $_REQUEST['alias'], 'config' => $_REQUEST['printertype']));
}
}
if ($PrinterManager->exists($_REQUEST['alias'])) {
throw new Exception('Printer already exists');
}
// Save
if ($Printer->save()) {
// Hook
$this->HookManager->processEvent('PRINTER_ADD_SUCCESS', array('Printer' => &$Printer));
// Log History event
$this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', _('Printer created'), $Printer->get('id'), $Printer->get('name')));
//Send message to user
$this->FOGCore->setMessage('Printer was created! Editing now!');
//Redirect to edit
$this->FOGCore->redirect('?node=printer&sub=edit&id=' . $Printer->get('id'));
} else {
throw new Exception('Something went wrong. Add failed');
}
} catch (Exception $e) {
// Hook
$this->HookManager->processEvent('PRINTER_ADD_FAIL', array('Printer' => &$Printer));
// Log History event
$this->FOGCore->logHistory(sprintf('%s add failed: Name: %s, Error: %s', _('User'), $_REQUEST['name'], $e->getMessage()));
// Set session message
$this->FOGCore->setMessage($e->getMessage());
// Redirect user.
$this->FOGCore->redirect($this->formAction);
}
}
}