public function index06Action() { echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>"; $filter = new \Zend\Filter\Digits(); $input = "\$%#\$\$%dsgsdgs123"; $output = $filter->filter($input); echo "<h2>Input: {$input}</h2><br>"; echo "<h2>Output : {$output}</h2>"; return false; }
public function filter($value) { $digitFilter = new \Zend\Filter\Digits(); $valueFiltered = $digitFilter->filter($value); if ($valueFiltered) { $regexValidator = new \Zend\Validator\Regex('/^(084)+/'); if ($regexValidator->isValid($valueFiltered)) { $valueFiltered = substr_replace($valueFiltered, '0', 0, 3); } else { $regexValidator->setPattern('/^(84)+/'); if ($regexValidator->isValid($valueFiltered)) { $valueFiltered = substr_replace($valueFiltered, '0', 0, 2); } } $regexValidator->setPattern('/^[0]/'); if (!$regexValidator->isValid($valueFiltered)) { $valueFiltered = '0' . $valueFiltered; } } return $valueFiltered; }
public function deleteAction() { if (!empty($this->_arrParam['id'])) { $filter = new \Zend\Filter\Digits(); $id = $filter->filter($this->_arrParam['id']); $arrParam = array('id' => $id); /*$item = $this->getTable()->getItem($this->_arrParam,array('task'=>'get-item')); $upload = new \ZendVN\File\Upload(); $upload->removeFile(UPLOAD_PATH .'/news/'.$item->images);*/ $this->getTable()->deleteItem($arrParam, array('task' => 'delete-item')); $this->flashMessenger()->addSuccessMessage('Dữ liệu đã được xóa thành công'); } $this->redirect()->toUrl('/admin/legislationhousing/'); return $this->getResponse(); }
public function statusAction() { if (!empty($this->_arrParam['id'])) { $filter = new \Zend\Filter\Digits(); $id = $filter->filter($this->_arrParam['id']); $arrParam = array('status' => $this->_arrParam['status'], 'id' => $id); $this->getTable()->saveItem($arrParam, array('task' => 'edit')); } $this->redirect()->toUrl('/admin/gallery/'); return $this->getResponse(); }
public function deleteAction() { if (!empty($this->_arrParam['id'])) { $filter = new \Zend\Filter\Digits(); $id = $filter->filter($this->_arrParam['id']); $arrParam = array('id' => $id); $this->getTable()->deleteItem($arrParam, array('task' => 'delete-item')); $this->flashMessenger()->addSuccessMessage('Dữ liệu đã được xóa thành công'); } $this->redirect()->toUrl('/admin/project-category/'); return $this->getResponse(); }
public function deleteAction() { if (!empty($this->_arrParam['id'])) { $filter = new \Zend\Filter\Digits(); $id = $filter->filter($this->_arrParam['id']); $arrParam = array('id' => $id); $item = $this->getTable()->getItem($this->_arrParam, array('task' => 'get-item')); $upload = new \ZendVN\File\Upload(); $images = \Zend\Json\Json::decode($item->images); if (!empty($images)) { foreach ($images as $image) { $upload->removeFile(UPLOAD_PATH . '/project/' . $image); } } $this->getTable()->deleteItem($arrParam, array('task' => 'delete-item')); $this->flashMessenger()->addSuccessMessage('Dữ liệu đã được xóa thành công'); } $this->redirect()->toUrl('/admin/project/'); return $this->getResponse(); }
/** * * @param unknown $entries * @param unknown $medias * @param string $template * @return string */ public function __invoke($entries, $template, $media) { $templateKey = static::VIEW_TEMPLATE; if (isset($entries['modulFormat'])) { $templateKey = $entries['modulFormat']; } $this->setTemplate($template->plugins->{$templateKey}); $filterDigits = new \Zend\Filter\Digits(); $html = ''; foreach ($entries['modulContent']['account'] as $entry) { if ('group' === $entries['modulContent']['grptype']) { $entry = $entry->accounts; } $cardData = ''; if ('_nomedia' != $entry->imgSource) { $cardData .= $this->deployRow($this->imagesSource, '<img src="' . $entry->imgSource . '" alt="' . $entry->organisation . '" />'); } $ext = $entry->organisationExt ? $this->organisation->organisationext . ' <span class="organization-further">' . $entry->organisationExt . '</span>' : ''; $cardData .= $this->deployRow($this->organisation, $entry->organisation . $ext); if (isset($this->address['grids'])) { $location = null; $grids = $this->address['grids']; if (strlen($entry->accountStreet) > 0) { if (isset($grids['accountStreet'])) { $num = $entry->accountStreetNumber ? ' ' . $entry->accountStreetNumber . '' : ''; $location .= $this->deployRow($grids['accountStreet'], $entry->accountStreet . $num); } } if (strlen($entry->accountZipcode) > 0) { if (isset($grids['accountZipcode'])) { $location .= $this->deployRow($grids['accountZipcode'], $entry->accountZipcode); } } if (strlen($entry->accountCity) > 0) { if (isset($grids['accountCity'])) { $location .= $this->deployRow($grids['accountCity'], $entry->accountCity); } } if (null !== $location) { $cardData .= $this->deployRow($this->address, $location); } } if ($this->phoneWork && strlen($entry->accountPhone) > 0) { $phoneWorkTemplate = $this->phoneWork->toArray(); $phoneWorkTemplate['grid']['attr']['href'] = $phoneWorkTemplate['grid']['attr']['href'] . $filterDigits->filter($entry->accountPhone); $cardData .= $this->deployRow($phoneWorkTemplate, $entry->accountPhone); } if ($this->phoneMobile && strlen($entry->phoneMobile) > 0) { $phoneMobileTemplate = $this->phoneMobile->toArray(); $phoneMobileTemplate['grid']['attr']['href'] = $phoneMobileTemplate['grid']['attr']['href'] . $filterDigits->filter($entry->phoneMobile); $cardData .= $this->deployRow($phoneMobileTemplate, $entry->phoneMobile); } if ($this->phoneFax && strlen($entry->accountFax) > 0) { $phoneFaxTemplate = $this->phoneFax->toArray(); $phoneFaxTemplate['grid']['attr']['href'] = $phoneFaxTemplate['grid']['attr']['href'] . $filterDigits->filter($entry->accountFax); $cardData .= $this->deployRow($phoneFaxTemplate, $entry->accountFax); } if ($this->accountEmail && strlen($entry->accountEmail) > 0) { $cardData .= $this->deployRow($this->accountEmail, $entry->accountEmail); } if ($this->internet && strlen($entry->internet) > 0) { $cardData .= $this->deployRow($this->internet, $entry->internet); } if ($this->description && strlen($entry->description) > 0) { $cardData .= $this->deployRow($this->description, $entry->description); } $html .= $this->deployRow($this->schema, $cardData); } if (null !== $this->wrapper) { $html = $this->deployRow($this->wrapper, $html); } return $html; }
public function deleteAction() { if (!empty($this->_arrParam['id'])) { $filter = new \Zend\Filter\Digits(); $id = $filter->filter($this->_arrParam['id']); $arrParam = array('id' => $id); $item = $this->getTable()->getItem($this->_arrParam, array('task' => 'get-item')); //không thể xóa tài khoản admin if ($item->group_id != 1) { $upload = new \ZendVN\File\Upload(); $upload->removeFile(UPLOAD_PATH . '/avatar/' . $item->avatar); $this->getTable()->deleteItem($arrParam, array('task' => 'delete-item')); } $this->flashMessenger()->addSuccessMessage('Dữ liệu đã được xóa thành công'); } $this->redirect()->toUrl('/admin/user/'); return $this->getResponse(); }
public function clonecompanyrolefeatureAction() { $form = new \System\Form\Tool\Clonecompanyrolefeature($this->getServiceLocator()); $dbSql = $this->getServiceLocator()->get('dbSql'); $dbAdapter = $this->getServiceLocator()->get('dbAdapter'); if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { $data = $form->getData(); // láy danh sách actionId $select = $dbSql->select(['f' => \Company\Model\Role\FeatureMapper::TABLE_NAME]); $select->where(['roleId' => $data['fromRoleId']]); $query = $dbSql->buildSqlString($select); $rows = $dbAdapter->query($query, $dbAdapter::QUERY_MODE_EXECUTE); $actionIds = []; if ($rows->count()) { foreach ($rows->toArray() as $row) { $actionIds[$row['actionId']] = $row['actionId']; } } $toCompanyIds = explode(',', $data['toCompanyId']); $digitFilter = new \Zend\Filter\Digits(); $companyRoleMapper = $this->getServiceLocator()->get('\\Company\\Model\\RoleMapper'); $roleFeatureMapper = $this->getServiceLocator()->get('\\Company\\Model\\Role\\FeatureMapper'); foreach ($toCompanyIds as $companyId) { $companyId = $digitFilter->filter($companyId); if (!$companyId) { continue; } // tạo role $companyRole = new \Company\Model\Role(); $companyRole->setCompanyId($companyId); $companyRole->setName($data['asRole']); if (!$companyRoleMapper->isExisted($companyRole)) { $companyRole->setCreatedById(1); $companyRole->setCreatedDateTime(DateBase::getCurrentDateTime()); $companyRoleMapper->save($companyRole); } foreach ($actionIds as $actionId) { $roleFeature = new \Company\Model\Role\Feature(); $roleFeature->setActionId($actionId); $roleFeature->setRoleId($companyRole->getId()); if (!$roleFeatureMapper->isExisted($roleFeature)) { $roleFeature->setCreatedById(1); $roleFeature->setCreatedDateTime(DateBase::getCurrentDateTime()); $roleFeatureMapper->save($roleFeature); } } echo 'done company ' . $companyId . '<br/>'; } } die; } $this->getViewModel()->setVariable('form', $form); return $this->getViewModel(); }
public function __invoke($entries, $template, $media) { $templateKey = static::VIEW_TEMPLATE; if (isset($entries['modulFormat'])) { $templateKey = $entries['modulFormat']; } $this->setTemplate($template->plugins->{$templateKey}); $filterDigits = new \Zend\Filter\Digits(); $html = ''; foreach ($entries['modulContent'] as $entry) { $cardData = ''; switch ($this->schemakey) { case 'Person': $human = $this->view->microdataname($entry); if (1 === $entry->enableImage && '_nomedia' != $entry->contacts->contactImgSource) { $cardData .= $this->deployRow($this->imagesSource, '<img src="' . $entry->contacts->contactImgSource . '" alt="' . $human . '" />'); } $cardData .= $this->deployRow($this->person, $human); if (1 === $entry->indexGroup->enableBusinessTitle && null != ($businesTitle = $this->view->microdataoverwrite($entry, 'contacts', 'businessTitle'))) { $cardData .= $this->deployRow($this->businessTitle, $businesTitle); } if (1 === $entry->indexGroup->enableOrganame) { $ext = $entry->indexGroup->accounts->organisationExt ? $this->organisation->organisationext . '<span class="organization-further">' . $entry->indexGroup->accounts->organisationExt . '</span>' : ''; $cardData .= $this->deployRow($this->organisation, $entry->indexGroup->accounts->organisation . $ext); } break; case 'Organization': if (1 === $entry->indexGroup->enableOrganame) { $ext = $entry->indexGroup->accounts->organisationExt ? $this->organisation->organisationext . '<span class="organization-further">' . $entry->indexGroup->accounts->organisationExt . '</span>' : ''; $cardData .= $this->deployRow($this->organisation, $entry->indexGroup->accounts->organisation . $ext); } $human = $this->view->microdataname($entry); if (1 === $entry->enableImage && '_nomedia' != $entry->contacts->contactImgSource) { $cardData .= $this->deployRow($this->imagesSource, '<img src="' . $entry->contacts->contactImgSource . '" alt="' . $human . '" />'); } $cardData .= $this->deployRow($this->person, $human); if (1 === $entry->indexGroup->enableBusinessTitle && null != ($businesTitle = $this->view->microdataoverwrite($entry, 'contacts', 'businessTitle'))) { $cardData .= $this->deployRow($this->businessTitle, $businesTitle); } default: } switch ($this->schemakey) { case 'Person': if ($this->address) { $location = null; $addressgrids = $this->address['grids']; if (1 === $entry->indexGroup->enableOrgaddress) { $account = $entry->indexGroup->accounts; if (strlen($account->accountStreet) > 0) { $street = $account->accountStreet; if (strlen($account->accountStreetNumber) > 0) { $street .= ' ' . $account->accountStreetNumber; } if (isset($addressgrids['accountStreet'])) { $location .= $this->deployRow($addressgrids['accountStreet'], $street); } } if (strlen($account->accountZipcode) > 0) { if (isset($addressgrids['accountZipcode'])) { $location .= $this->deployRow($addressgrids['accountZipcode'], $account->accountZipcode); } } if (strlen($account->accountCity) > 0) { if (isset($addressgrids['accountCity'])) { $location .= $this->deployRow($addressgrids['accountCity'], $account->accountCity); } } } elseif (1 === $entry->indexGroup->enableAddress) { if (null != ($contactAdress = $this->view->microdataoverwrite($entry, 'contacts', 'contactAddress'))) { if (isset($addressgrids['accountStreet'])) { $location .= $this->deployRow($addressgrids['accountStreet'], $contactAdress); } } if (null != ($contactZipcode = $this->view->microdataoverwrite($entry, 'contacts', 'contactZipcode'))) { if (isset($addressgrids['accountZipcode'])) { $location .= $this->deployRow($addressgrids['accountZipcode'], $contactZipcode); } } if (null != ($contactCity = $this->view->microdataoverwrite($entry, 'contacts', 'contactCity'))) { if (isset($addressgrids['accountCity'])) { $location .= $this->deployRow($addressgrids['accountCity'], $contactCity); } } } if (null !== $location) { $cardData .= $this->deployRow($this->address, $location); } } if (1 === $entry->enablePhoneHome && null != $entry->contacts->phoneHome) { $phoneHomeTemplate = $this->phoneHome->toArray(); $phoneHomeTemplate['grid']['attr']['href'] = $phoneHomeTemplate['grid']['attr']['href'] . $filterDigits->filter($entry->contacts->phoneHome); $cardData .= $this->deployRow($phoneHomeTemplate, $entry->contacts->phoneHome); } if (1 === $entry->enablePhoneMobile && null != ($phoneMobile = $this->view->microdataoverwrite($entry, 'contacts', 'phoneMobile'))) { $phoneMobileTemplate = $this->phoneMobile->toArray(); $phoneMobileTemplate['grid']['attr']['href'] = $phoneMobileTemplate['grid']['attr']['href'] . $filterDigits->filter($phoneMobile); $cardData .= $this->deployRow($phoneMobileTemplate, $phoneMobile); } if (1 === $entry->enablePhoneWork && null != ($phoneWork = $this->view->microdataoverwrite($entry, 'contacts', 'phoneWork'))) { $phoneWorkTemplate = $this->phoneWork->toArray(); $phoneWorkTemplate['grid']['attr']['href'] = $phoneWorkTemplate['grid']['attr']['href'] . $filterDigits->filter($phoneWork); $cardData .= $this->deployRow($phoneWorkTemplate, $phoneWork); } if (1 === $entry->enablePhoneFax && null != ($phoneFax = $this->view->microdataoverwrite($entry, 'contacts', 'phoneFax'))) { $phoneFaxTemplate = $this->phoneFax->toArray(); $phoneFaxTemplate['grid']['attr']['href'] = $phoneFaxTemplate['grid']['attr']['href'] . $filterDigits->filter($phoneFax); $cardData .= $this->deployRow($phoneFaxTemplate, $phoneFax); } if (1 === $entry->enableContactEmail && null != ($contactEmail = $this->view->microdataoverwrite($entry, 'contacts', 'contactEmail'))) { $cardData .= $this->deployRow($this->accountEmail, $contactEmail); } elseif (1 === $entry->enableContactEmail && strlen($entry->indexGroup->accounts->accountEmail) > 0) { $cardData .= $this->deployRow($this->accountEmail, $entry->indexGroup->accounts->accountEmail); } if (1 === $entry->enableAlternateEmail && null != $entry->contacts->alternateEmail) { $cardData .= $this->deployRow($this->alternateEmail, $entry->contacts->alternateEmail); } if (1 === $entry->enableInternet && null != ($internet = $this->view->microdataoverwrite($entry, 'contacts', 'internet'))) { $cardData .= $this->deployRow($this->internet, $internet); } elseif (1 === $entry->enableInternet && strlen($entry->indexGroup->accounts->internet) > 0) { $cardData .= $this->deployRow($this->internet, $entry->indexGroup->accounts->internet); } if (1 === $entry->enableDescription && null != ($description = $this->view->microdataoverwrite($entry, 'contacts', 'description'))) { $cardData .= $this->deployRow($this->description, $description); } break; case 'Organization': if ($this->address) { if (1 === $entry->indexGroup->enableOrgaddress) { $account = $entry->indexGroup->accounts; if (strlen($account->accountStreet) > 0) { $street = $account->accountStreet; if (strlen($account->accountStreetNumber) > 0) { $street .= ' ' . $account->accountStreetNumber; } if (isset($grids['accountStreet'])) { $location .= $this->deployRow($addressgrids['accountStreet'], $street); } } if (strlen($account->accountZipcode) > 0) { if (isset($addressgrids['accountZipcode'])) { $location .= $this->deployRow($addressgrids['accountZipcode'], $account->accountZipcode); } } if (strlen($account->accountCity) > 0) { if (isset($grids['accountCity'])) { $location .= $this->deployRow($addressgrids['accountCity'], $account->accountCity); } } } } $account = $entry->indexGroup->accounts; if (1 === $entry->enablePhoneWork) { if (strlen($entry->contacts->phoneWork) > 1) { $workPhone = $entry->contacts->phoneWork; } elseif (strlen($account->accountPhone) > 0) { $workPhone = $account->accountPhone; } $phoneWorkTemplate = $this->phoneWork->toArray(); $phoneWorkTemplate['grid']['attr']['href'] = $phoneWorkTemplate['grid']['attr']['href'] . $filterDigits->filter($account->accountPhone); $cardData .= $this->deployRow($phoneWorkTemplate, $workPhone); } /* if (1 === $entry->enablePhoneWork && strlen($account->accountPhone) > 0) { $phoneWorkTemplate = $this->phoneWork->toArray(); $phoneWorkTemplate['grid']['attr']['href'] = $phoneWorkTemplate['grid']['attr']['href'] . $filterDigits->filter($account->accountPhone); $cardData .= $this->deployRow($phoneWorkTemplate, $account->accountPhone); }*/ if (1 === $entry->enablePhoneFax && strlen($account->accountFax) > 0) { $phoneFaxTemplate = $this->phoneFax->toArray(); $phoneFaxTemplate['grid']['attr']['href'] = $phoneFaxTemplate['grid']['attr']['href'] . $filterDigits->filter($account->accountFax); $cardData .= $this->deployRow($phoneFaxTemplate, $account->accountFax); } if (1 === $entry->enableContactEmail && strlen($account->accountEmail) > 0) { $cardData .= $this->deployRow($this->accountEmail, $account->accountEmail); } elseif (1 === $entry->enableContactEmail && null != ($contactEmail = $this->view->microdataoverwrite($entry, 'contacts', 'contactEmail'))) { $cardData .= $this->deployRow($this->accountEmail, $contactEmail); } if (1 === $entry->enableAlternateEmail && null != $entry->contacts->alternateEmail) { $cardData .= $this->deployRow($this->alternateEmail, $entry->contacts->alternateEmail); } if (1 === $entry->enableInternet && strlen($account->internet) > 0) { $cardData .= $this->deployRow($this->internet, $account->internet); } default: } $html .= $this->deployRow($this->schema, $cardData); } if (null !== $this->wrapper) { $html = $this->deployRow($this->wrapper, $html); } return $html; }
public function deleteAction() { if (!empty($this->_arrParam['id'])) { $filter = new \Zend\Filter\Digits(); $id = $filter->filter($this->_arrParam['id']); $arrParam = array('id' => $id); $item = $this->getTable()->getItem($this->_arrParam, array('task' => 'get-item')); //-------Tiến hành xóa toàn bộ file của folder trước $upload = new \ZendVN\File\Upload(); $folder = FILE_MANAGER_URL_CODINH . '/' . $item->name; $fileList = scandir($folder); foreach ($fileList as $file) { if ($file != '.' && $file != '..') { $upload->removeFile(FILE_MANAGER_PATH . '/' . $item->name . '/' . $file); } } //--------Sau đó xóa folder----------------------------- @rmdir(FILE_MANAGER_URL_CODINH . '/' . $item->name); $this->getTable()->deleteItem($arrParam, array('task' => 'delete-folder')); $this->flashMessenger()->addSuccessMessage('Dữ liệu đã được xóa thành công'); } $this->redirect()->toUrl('/admin/filemanager/'); return $this->getResponse(); }