本文整理汇总了PHP中Factory::getView方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getView方法的具体用法?PHP Factory::getView怎么用?PHP Factory::getView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::getView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ActivityKey
$activity = Factory::getView(new ActivityKey($_REQUEST['id']));
$activity->requestDelete();
$transaction->commit();
break;
case 'create':
$transaction = new Transaction(new MySqlDB());
$transaction->start();
$activity = Factory::createView(new ActivityKey());
$activity->setUser($user);
$activity->setImportNumber(-1);
$activity->setImportTime(new Date());
$activity->setName($data['name']);
$activity->setTransactionDate(new Date($_POST['data']['transdate']));
$activity->setAmount($data['amount']);
if ($data['category'] != null && trim($data['category']) && $data['category'] != 'null') {
$activity->setCategory(Factory::getView(new CategoryKey(trim($data['category']))));
}
$transaction->commit();
break;
}
echo json_encode(array('success' => 'true'));
} else {
$smarty = new MySmarty($SMARTY_CONFIG);
$smarty->assign('res', $user->getActivities());
$userCategories = Category::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
$allCategories = Category::getOptions(array("ACTIVE" => 1));
$categories = '';
foreach ($userCategories as $index => $value) {
$categories .= "{\"value\": \"{$index}\", \"label\": \"{$value}\"},";
}
$smarty->assign('allCategories', $categories);
示例2: MySmarty
$user = $access->getUser();
$smarty = new MySmarty($SMARTY_CONFIG);
$smarty->assign('user', $user);
$transaction = false;
if (!empty($_POST)) {
if (!array_key_exists('csv_file', $_FILES)) {
throw new Exception("Missing required parameter: file");
}
if (!array_key_exists('mapping_type', $_REQUEST)) {
throw new Exception("Missing required parameter: mapping type");
} else {
$mapping_key = htmlentities($_REQUEST['mapping_type']);
}
$transaction = new Transaction(new MySqlDB());
$transaction->start();
$mapping = Factory::getView(new MappingKey($mapping_key));
$importNumber = rand(10000000000, 99999999999);
$importTime = new Date();
$tmpname = $_FILES['csv_file']['tmp_name'];
if (($handle = fopen($tmpname, "r")) !== FALSE) {
$row = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$row++;
if ($row < $mapping->getStartingRow()) {
// Getting to starting row;
continue;
}
$activity = Factory::createView(new ActivityKey());
$activity->setImportNumber($importNumber);
$activity->setImportTime(new Date());
$activity->setUser($user);
示例3: htmlentities
//TODO: check amount is valid
$budgetedAmount = htmlentities($_POST['budgetedAmount']);
$transaction = new Transaction(new MySqlDB());
$transaction->start();
$budget = Factory::createView(new BudgetKey());
$category = Factory::getView(new CategoryKey($categoryId));
$budget->setUser($user);
$budget->setActive(TRUE);
$budget->setAmount($budgetedAmount);
$budget->setCategory($category);
$transaction->commit();
} elseif ($action === "remove") {
$key = htmlentities($_POST['key']);
$transaction = new Transaction(new MySqlDB());
$transaction->start();
$budgetItem = Factory::getView(new BudgetKey($key));
$budgetItem->setActive(0);
$transaction->commit();
}
}
$budgets = Budget::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
$spent = array();
$budgetLeft = array();
foreach ($budgets as $key => $item) {
$activities = Activity::getOptions(array("USER_ID" => $user->getId(), "CATEGORY_ID" => $item['category_id'], "TRANSACTION_DATE_START" => Date::firstOfMonth()));
$value = 0;
foreach ($activities as $activityKey => $activityItem) {
$value += $activityItem['amount'];
}
$spent[$key] = 0 - $value;
$budgetLeft[$key] = $item['amount'] + $value;
示例4: htmlentities
$action = htmlentities($_POST['action']);
if ($action === "add") {
$categoryName = htmlentities($_POST['categoryName']);
$transaction = new Transaction(new MySqlDB());
$transaction->start();
$category = Factory::createView(new CategoryKey());
$category->setUser($user);
$category->setActive(TRUE);
$category->setName($categoryName);
$transaction->commit();
} elseif ($action === "remove") {
try {
$key = htmlentities($_POST['key']);
$transaction = new Transaction(new MySqlDB());
$transaction->start();
$categoryItem = Factory::getView(new CategoryKey($key));
$categoryItem->setActive(0);
$transaction->commit();
} catch (Exception $e) {
print_r($e);
}
}
}
$userCategories = Category::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
$allCategories = Category::getOptions(array("ACTIVE" => 1));
$smarty->assign('allCategories', $allCategories);
$smarty->assign('userCategories', $userCategories);
if ($fullPage) {
$smarty->assign('user', $user);
$smarty->assign('left_menu', true);
$smarty->display('category.tpl');