本文整理匯總了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);
}
}
}