コード例 #1
0
 protected function init($checkLogin = true)
 {
     $this->noCache();
     //Set password salt for user
     \ATPAdmin\Model\User::setPasswordSalt($this->config('admin.auth.password_salt'));
     //Check for logged in user
     $this->_validLogin = !$checkLogin || !$this->_checkLogin || \ATPAdmin\Auth::isLoggedIn();
     if (!$this->_validLogin) {
         $this->redirect()->toRoute('admin', array('action' => 'login'));
     }
     //Set the admin layout
     $this->layout("atp-admin/layout/admin");
     //Get the model information
     $this->models = $this->config('admin.models');
     $this->reports = $this->config('admin.reports');
     //Setup the view
     $this->view = new \Zend\View\Model\ViewModel();
     //Get the flash messenger
     $this->flash = $this->flashMessenger();
     $this->layout()->addChild(new \ATPCore\View\Widget\FlashWidget($this->flash), 'flash');
     //Create the admin menu
     $adminMenu = array();
     //Add the models
     foreach ($this->models as $model => $modelData) {
         if (!isset($adminMenu[$modelData['category']])) {
             $adminMenu[$modelData['category']] = array();
         }
         $linkData = array('action' => 'list', 'model' => \ATP\Inflector::underscore($model));
         if (isset($modelData['custom_actions']['list'])) {
             $linkData['controller'] = $modelData['custom_actions']['list']['controller'];
             $linkData['action'] = $modelData['custom_actions']['list']['action'];
         }
         $adminMenu[$modelData['category']][] = array('label' => \ATP\Inflector::pluralize($modelData['displayName']), 'linkData' => $linkData);
     }
     //Add the reports
     foreach ($this->reports as $report => $reportData) {
         if (!isset($adminMenu[$reportData['category']])) {
             $adminMenu[$reportData['category']] = array();
         }
         $adminMenu[$reportData['category']][] = array('label' => $reportData['label'], 'linkData' => array('action' => 'report', 'model' => $report));
     }
     $this->layout()->menu = $adminMenu;
     //Load the model data if needed
     $this->modelType = $this->params('model');
     if (!empty($this->modelType) && $this->params('action') != 'report') {
         $this->modelData = $this->models[$this->modelType];
     }
 }
コード例 #2
0
 public function postAction()
 {
     $field = new \ATPContact\Model\Field();
     $fields = $field->loadMultiple(array('orderBy' => 'sort_order ASC'));
     $messageData = array();
     foreach ($fields as $field) {
         $name = \ATP\Inflector::underscore($field->label);
         $messageData[$field->label] = $this->params()->fromPost($name);
     }
     $messageHtml = $this->siteParam('contact-email-template');
     foreach ($messageData as $name => $value) {
         $messageHtml = str_replace('{' . $name . '}', $value, $messageHtml);
     }
     $messageText = strip_tags($messageHtml);
     $replyToField = new \ATPContact\Model\Field();
     $replyToField->loadById($this->siteParam('contact-reply-to-field'));
     $sesMessage = ['Destination' => ['ToAddresses' => [$this->siteParam('contact-email-to')]], 'ReplyToAddresses' => [$messageData[$replyToField->label]], 'Source' => $this->siteParam('contact-email-from'), 'Message' => ['Subject' => ['Data' => $this->siteParam('contact-subject')], 'Body' => ['Text' => ['Data' => $messageText], 'Html' => ['Data' => $messageHtml]]]];
     $result = $this->getServiceLocator()->get(\Aws\Sdk::class)->createSes()->sendEmail($sesMessage);
     //TODO: add confirmation message
     $this->flash = $this->flashMessenger();
     $this->flash->addSuccessMessage($this->siteParam('contact-success-message'));
     //TODO: forward back to contact page
     $this->redirect()->toRoute('contact');
 }
コード例 #3
0
ファイル: ActiveRecord.php プロジェクト: daemonalchemist/atp
 private function _getChildren($func, $params)
 {
     $parts = explode("By", $func);
     if (count($parts) > 2) {
         throw new \ATP\ActiveRecord\Exception("Ambiguous children call {$func}");
     }
     $table = \ATP\Inflector::underscore(substr($parts[0], 3));
     $field = \ATP\Inflector::underscore($parts[1]) . "_id";
     $class = self::$_databaseDef['tables'][$table]['class'];
     $obj = new $class();
     $children = $obj->loadMultiple(array('where' => "{$field} = ?", 'data' => array($this->id)));
     return $children;
 }
コード例 #4
0
ファイル: ModelList.php プロジェクト: daemonalchemist/atp
 public function temp()
 {
     $models = \Zend_Registry::get('config')->models->toArray();
     $className = $models[\ATP\Inflector::camelize($this->_type)]['class'];
     return new $className();
 }