$longDescription = ""; $purpose = ""; $contactInfo = ""; $showStat = false; $additionAmount = 0.0; $formRequestUrl = "/add-orphanage-controller.php"; if (isset($orphanage)) { $avatar = "<img src='" . get_site_url() . ImageDBUtils::getImageLinkByImageId($orphanage->image_id) . "' class='file-preview-image' alt='avatar' title='avatar'>"; $name = $orphanage->name; $orphanagePriority = $orphanage->priority; $shortDescription = $orphanage->short_description; $longDescription = $orphanage->long_description; $contactInfo = $orphanage->contact_info; $purpose = $orphanage->purpose; $showStat = NeedyItemSettingsDBUtils::isSetShowOrphanageStat($orphanage->orphanage_id); $additionAmountObj = NeedyItemSettingsDBUtils::getAdditionAmount($child->child_id, NeedyType::ORPHANAGE); $additionAmount = $additionAmountObj->addition_amount; $formRequestUrl = "/edit-orphanage-controller.php"; } get_header(); ?> <div class="child-form"> <div class="container"> <div id="kv-avatar-errors" class="center-block" style="width:800px;display:none"></div> <form name="orphanage_form" action="<?php echo esc_url(home_url($formRequestUrl)); ?> " method="post" enctype="multipart/form-data"> <div class="col"> <div class="col-md-3">
<?php require_once __DIR__ . '/wp-load.php'; require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php'; require_once ABSPATH . WPINC . '/lib/validator/class-child-form-validator.php'; require_once ABSPATH . WPINC . '/lib/utils/db/class-child-db-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php'; if (!is_user_logged_in()) { wp_redirect(home_url()); exit; } $childInfo = RequestHelper::getChildInfoFromRequest(); if (ChildFormValidator::validateAddChildParameters($childInfo)) { $image = ImageUtils::createImageFromRequestParameters($childInfo); if ($image) { $childId = ChildDBUtils::createChild($childInfo, $image->image_id); NeedyItemSettingsDBUtils::updateChildSettings($childId, $childInfo); } } wp_redirect(home_url()); exit;
if ($needyItem->purpose && $needyItem->status != NeedyStatus::HELPED) { ?> <p class="purpose"><span>Нужно: </span><?php echo $needyItem->purpose; ?> </p> <?php } ?> <?php if (NeedyItemSettingsDBUtils::isSetShowNeedyItemStat($needyItem->needy_id, $needyItem->needy_type)) { ?> <?php $collected = NeedyStatDBUtils::getNeedyItemStat($needyItem->needy_id, $needyItem->needy_type); $addition = NeedyItemSettingsDBUtils::getAdditionAmount($needyItem->needy_id, $needyItem->needy_type); $result = $collected->amount + $addition->addition_amount; ?> <p class="collected"><span>Собрано: </span><?php echo intval($result); ?> руб. <span class="count-donate"><img src="<?php echo get_template_directory_uri(); ?> /images/count_donate.png" alt="" /><?php echo intval($collected->count); ?> </span></p> <?php } ?>
<?php require_once __DIR__ . '/wp-load.php'; require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php'; require_once ABSPATH . WPINC . '/lib/validator/class-orphanage-form-validator.php'; require_once ABSPATH . WPINC . '/lib/utils/db/class-orphanage-db-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php'; if (!is_user_logged_in()) { wp_redirect(home_url()); exit; } $orphanageInfo = RequestHelper::getOrphanageInfoFromRequest(); if (OrphanageFormValidator::validateAddOrphanageParameters($orphanageInfo)) { $image = ImageUtils::createImageFromRequestParameters($orphanageInfo); if ($image) { $orphanageId = OrphanageDBUtils::createOrphanage($orphanageInfo, $image->image_id); NeedyItemSettingsDBUtils::updateOrphanageSettings($orphanageId, $orphanageInfo); } } wp_redirect(home_url()); exit;
<?php require_once __DIR__ . '/wp-load.php'; require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php'; require_once ABSPATH . WPINC . '/lib/validator/class-child-form-validator.php'; require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/db/class-child-db-utils.php'; require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php'; if (!is_user_logged_in()) { wp_redirect(home_url()); exit; } $childInfo = RequestHelper::getChildInfoFromRequest(); if (ChildFormValidator::validateEditChildParameters($childInfo)) { $child = ChildDBUtils::getChildById($childInfo[Child::ID_FIELD]); $imageId = $child->image_id; if ($child && ChildFormValidator::validateChildAvatar($childInfo)) { $image = ImageUtils::createImageFromRequestParameters($childInfo); if ($image) { ImageUtils::deleteImageById($child->image_id); $imageId = $image->image_id; } } ChildDBUtils::updateChildById($childInfo, $imageId, $child->child_id); $result = NeedyItemSettingsDBUtils::updateChildSettings($child->child_id, $childInfo); } wp_redirect(home_url()); exit;