/** * @param $xml * @return mixed */ public function execBlock($xml) { $errors = array(); $submit = false; $values = $this->request->getGPAsArray(); if ($this->request->post('mailform')) { $submit = true; $required = $values['required']; $fields = $values['field']; $this->validation->setData($fields); $this->validation->addRule('email', 'email'); $errorMessages = array(); foreach ($required as $field => $val) { $this->validation->addRule($field, 'notEmpty'); $errorMessages = array_merge($errorMessages, array($field => array($field => $this->translation->getTranslation('Please fill out the field')))); } $this->validation->setErrorMessages($errorMessages); $check = $this->validation->check(); if ($check === true) { $msg = $this->mail->getMessageInstance(); $msg->setFrom(array($fields['email'])); $msg->setSubject($this->config->get('MAILFORM_SUBJECT')->value); $msg->setTo(explode(',', $this->config->get('MAILFORM_TO')->value)); $this->template->assign('fields', $fields); $msg->setBody($this->template->fetch('Extension/Mailform/Mail'), 'text/html'); $this->mail->send(); } else { $errors = $check; } } $this->mailformController->renderHtml($submit, $values, $errors); }
/** * Paste copied block */ private function pasteBlock() { $blockId = $this->request->gp('blockId'); $op = $this->request->gp('op', 'copy') == 'copy' ? 'copy' : 'cut'; $byRef = $this->request->gp('byRef', false) === 'true' ? true : false; $menuId = $this->request->gp('menuId', false); $contentId = $this->request->gp('contentId', false); if ($contentId && $blockId && ($block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId))) { if ($op === 'copy') { $copiedBlock = clone $block; $copiedBlock->id = null; $copiedBlock->contentId = $contentId; $copiedBlock->menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuId); if ($byRef === true) { $copiedBlock->config = null; if ($block->byRef) { $block = $block->byRef; $copiedBlock->byRef = $block; } $copiedBlock->byRef = $block; } $this->db->persist($copiedBlock); $block = $copiedBlock; } else { $block->menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuId); $block->contentId = $contentId; $this->db->persist($block); } $this->db->flush(); $this->response->sendAsJson(array('success' => true, 'data' => $this->prepareBlockOutput($block))); } $this->response->sendAsJson(array('success' => false, 'message' => $this->translation->getTranslation('Paste error, please copy again'))); }
/** * @return mixed */ public function getAdminPanel() { $extensions = $this->db->getRepository('\\Fraym\\SiteManager\\Entity\\Extension')->findBy(array('active' => 1), array('sorter' => 'asc')); $extensionSorted = array(); foreach ($extensions as $extension) { if (!isset($extensionSorted[$extension->id])) { $extensionSorted[$extension->id] = array(); } $extensionSorted[$extension->id] = array('name' => $this->translation->getTranslation($extension->name, 'SITE_EXT_' . strtoupper(str_ireplace(' ', '_', $extension->name))), 'iconCssClass' => $extension->iconCssClass); } uasort($extensionSorted, function ($a, $b) { return strcasecmp($a['name'], $b['name']); }); $this->view->assign('extensions', $extensionSorted); $this->view->assign('inEditMode', $this->block->inEditMode()); return $this->getIframeContent($this->view->fetch('AdminPanelContent'), array('cssClass' => 'admin-panel')); }
/** * @param $prop * @param $value * @param $modelName * @param $validationRule * @return mixed */ public function getErrorMessage($prop, $value, $modelName, $validationRule) { $className = str_ireplace('\\', '_', $modelName); $messages = Validation::DEFAULT_ERROR_TRANSLATIONS; $rule = strtoupper($validationRule); $key = 'FIELD_ERROR' . strtoupper($className) . '_' . strtoupper($prop) . '_' . $rule; $default = isset($messages[$rule]) ? $messages[strtoupper($validationRule)] : $key; return $this->translation->getTranslation($default, $key); }
/** * Paste copied block */ protected function pasteBlock() { $blockId = $this->request->gp('blockId'); $op = $this->request->gp('op', 'copy') == 'copy' ? 'copy' : 'cut'; $byRef = $this->request->gp('byRef', false) === 'true' ? true : false; $menuId = $this->request->gp('menuId', false); $contentId = $this->request->gp('contentId', false); if ($contentId && $blockId && ($block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId))) { $menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuId); $blocks = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findBy(['menuItem' => $menuItem, 'contentId' => $contentId], ['position' => 'asc']); // Re-Order other blocks foreach ($blocks as $k => $b) { $b->position = $k + 1; } if ($op === 'copy') { $block = $block->changeSets->count() ? $block->changeSets->last() : $block; $copiedBlock = clone $block; $copiedBlock->id = null; $copiedBlock->position = 0; $copiedBlock->contentId = $contentId; $copiedBlock->menuItem = $menuItem; if ($byRef === true) { $copiedBlock->config = null; if ($block->byRef) { $block = $block->byRef; $copiedBlock->byRef = $block; } $copiedBlock->byRef = $block; } $changedBlock = $this->createChangeSet($copiedBlock, null, \Fraym\Block\Entity\ChangeSet::ADDED); } else { $changedBlock = $block->changeSets->count() ? $block->changeSets->last() : $block; $changedBlock->position = 0; $changedBlock->menuItem = $menuItem; $changedBlock->contentId = $contentId; $this->createChangeSet($changedBlock, $block, \Fraym\Block\Entity\ChangeSet::MOVED); } $this->db->flush(); $this->response->sendAsJson(['success' => true, 'data' => $this->prepareBlockOutput($changedBlock)]); } $this->response->sendAsJson(['success' => false, 'message' => $this->translation->getTranslation('Paste error, please reload the page and copy again.')]); }
/** * @param $xml * @return mixed */ public function execBlock($xml) { $errors = []; $submit = false; $values = $this->request->getGPAsArray(); $requiredFields = $this->getRequiredFields($xml); $formHash = $this->createFormHash($requiredFields); if ($this->request->post('mailform')) { $required = $values['required']; $fields = $values['field']; if ($this->isFormValid($formHash, $this->getValidationRules($required))) { $submit = true; $this->validation->setData($fields); $this->validation->addRule('email', 'email'); $errorMessages = []; foreach ($requiredFields as $field => $val) { $this->validation->addRule($field, $val['rule'], $val['param']); $errorMessages = array_merge($errorMessages, [$field => [$field => $this->translation->getTranslation('Please fill out the field')]]); } $this->validation->setErrorMessages($errorMessages); $check = $this->validation->check(); if ($check === true) { $config = json_decode($xml->mailformOptions, true); $receiver = $config[$this->locale->getLocale()->id]['email']; $subject = $config[$this->locale->getLocale()->id]['subject']; $msg = $this->mail->getMessageInstance(); $msg->setFrom([$fields['email']]); $msg->setSubject($subject); $msg->setTo(explode(',', $receiver)); $this->template->assign('fields', $fields, false); $msg->setBody($this->template->fetch('Extension/Mailform/Mail'), 'text/html'); $this->mail->send(); } else { $errors = $check; } } } $this->mailformController->renderHtml($submit, $values, $errors); }
/** * @param $prop * @param $value * @param $modelName * @param $validationRule * @return mixed */ public function getErrorMessage($prop, $value, $modelName, $validationRule) { $className = str_ireplace('\\', '_', $modelName); return str_ireplace("#{$prop}", "{$value}", $this->translation->getTranslation('FIELD_ERROR' . strtoupper($className) . '_' . strtoupper($prop) . '_' . strtoupper($validationRule))); }