public function process() { $params = Toolkit::i()->request->getParams(); if (count($params) < 2) { echo "Please specify module and command\n"; } else { $module = $params[0]; $controller = $params[1]; Core::import('Modules.' . $module); $sController = $module . $controller . 'Command'; $sControllerFull = 'ruxon\\modules\\' . $module . '\\commands\\' . $sController; if (class_exists($sControllerFull)) { $oController = new $sControllerFull(); } else { $oController = new $sController(); } unset($params[0]); unset($params[1]); $par = array_values($params); $action_params = array(); if (count($par)) { foreach ($par as $k => $val) { if (substr_count($val, "=") > 0) { $tmp = explode("=", $val); $action_params[$tmp[0]] = trim($tmp[1]); } else { $action_params[] = $val; } } } $oController->run('Execute', $action_params); } }
/** * Редактирование записи * * @param array $params * @return \ActionResponse */ public function actionUpdate($params = array()) { $errors = array(); $model = $this->mapper()->findById($params['id']); if (!empty($_POST)) { $attr = $_POST; unset($attr['Cover']); unset($attr['File']); $model->import($attr); if (!empty($_FILES['Cover']['name'])) { $model->setCover(\Toolkit::i()->fileStorage->bucket('images')->saveUploadedFile($model, 'Cover')); } if (!empty($_POST['Cover_delete'])) { \Toolkit::i()->fileStorage->bucket('images')->removeFile($model->getCover()); $model->setCover(''); } if (!empty($_FILES['File']['name'])) { $model->setFile(\Toolkit::i()->fileStorage->bucket('files')->saveUploadedFile($model, 'File')); } if (!empty($_POST['File_delete'])) { \Toolkit::i()->fileStorage->bucket('files')->removeFile($model->getFile()); $model->setFile(''); } if ($model->save()) { $this->redirect(array('index')); } else { $errors = $model->getErrors(); } } return $this->view('Update', array('Model' => $model, 'Errors' => $errors)); }
public function render() { if ($this->getValue()) { $file = Toolkit::i()->fileStorage->bucket($this->getBucketName())->getFile($this->getValue()); echo '<a target="_blank" href="' . $file->getFileUrl() . '">' . $this->getValue() . '</a>'; echo '<br />'; echo FormHelper::checkbox($this->getAlias() . '_delete', false, ['id' => $this->getAlias() . '_delete']); echo ' ' . FormHelper::labelFor($this->getAlias() . '_delete', 'Удалить'); } echo FormHelper::file($this->getAlias(), $this->getValue(), array('id' => 'field_' . $this->getAlias())); }
public function render() { if ($this->getValue()) { $file = Toolkit::i()->fileStorage->bucket($this->getBucketName())->getImage($this->getValue()); echo '<img src="' . $file->getThumbUrl(100) . '" alt="" />'; echo '<br />'; echo FormHelper::checkbox($this->getAlias() . '_delete', false, ['id' => $this->getAlias() . '_delete']); echo ' ' . FormHelper::labelFor($this->getAlias() . '_delete', 'Удалить'); } echo FormHelper::file($this->getAlias(), $this->getValue(), array('id' => 'field_' . $this->getAlias())); }
public function raise($alias, $recipients, $params = array(), $subject = '') { if (!is_array($recipients)) { $recipients = array($recipients); } Toolkit::i()->mail->ClearAddresses(); Toolkit::i()->mail->From = $this->fromEmail; Toolkit::i()->mail->FromName = $this->fromName; foreach ($recipients as $email) { Toolkit::i()->mail->AddAddress($email); } Toolkit::i()->mail->Subject = $subject; $emailTemplate = new MailTemplate($params); Toolkit::i()->mail->SetHtmlBody($emailTemplate->fetch($alias)); return Toolkit::i()->mail->Send(); }
public static function getParams() { return Toolkit::i()->urlManager->getParams(); }
public function process() { $sUrl = $this->getToolkit()->getRequest()->getUrl(); $sUrl = substr($sUrl, 1); $nStatusCode = 200; if (strpos($sUrl, "?") === 0) { $sUrl = ""; } if ($sUrl) { if (strrpos($sUrl, "/") === mb_strlen($sUrl) - 1) { $sUrl = substr($sUrl, 0, strrpos($sUrl, "/")); } $aRules = $this->getRules(); $aParams = array(); $bSuccess = false; foreach ($aRules as $rule) { $aRs = array(); if (preg_match("#^" . $rule['Pattern'] . "#", $sUrl, $aRs)) { $bSuccess = true; foreach ($rule['Params'] as $key => $value) { if (strpos($value, "\$") === 0) { $aParams[$key] = $aRs[str_replace("\$", "", $value)]; } else { $aParams[$key] = $value; } } break; } } if ($bSuccess) { $url = implode("/", $aParams); foreach ($aParams as $key => $value) { $aParams[$key] = str_replace(" ", "", ucwords(str_replace("_", " ", mb_strtolower($value)))); } $cleanUrl = substr($sUrl, 0, strlen($url)); $cleanUrlParams = substr($sUrl, strlen($url) + 1); Toolkit::i()->urlManager->parseUrlParams($cleanUrlParams); Toolkit::i()->request->setCleanUrl($cleanUrl); if (isset($_GET[$sUrl])) { unset($_GET[$sUrl]); } if (count($_GET)) { $aParams = array_merge($aParams, $_GET); } // Exec action } else { $aParams = array('Module' => 'App', 'Controller' => 'Index', 'Action' => '404'); $nStatusCode = 404; // 404 page not found } } else { // Main page $aParams = $this->getDefault(); } $this->executeRequest($nStatusCode, $aParams); }
<p class="blog-post-meta"><?php echo DateHelper::niceDateTime($item->getPostDate()); ?> <?php if (Toolkit::i()->auth->isAdmin()) { ?> <a href="<?php echo Toolkit::i()->urlManager->createUrl('blog/index/update', array('id' => $item->getId())); ?> "><?php echo $this->t('Basic', 'Edit'); ?> </a> <a class="red" href="<?php echo Toolkit::i()->urlManager->createUrl('blog/index/delete', array('id' => $item->getId())); ?> "><?php echo $this->t('Basic', 'Delete'); ?> </a> <?php } ?> </p> <?php echo $item->getContent(); ?> </div><!-- /.blog-post --> <?php
} ?> </div><!-- /.blog-post --> <div class="blog-comments"> <h3><?php echo $this->t('Basic', 'Comments'); ?> </h3> <?php $this->widget('Blog', 'CommentsList', ['ObjectId' => $this->getModel()->getId()]); ?> <h3><?php echo $this->t('Basic', 'Add comment'); ?> </h3> <?php $this->widget('Blog', 'CommentCreate', ['ObjectId' => $this->getModel()->getId()]); ?> </div> <div> <a href="<?php echo Toolkit::i()->urlManager->createUrl('blog/index/index'); ?> "><?php echo $this->t('Basic', 'Back to list'); ?> </a> </div>
foreach ($this->getErrors() as $error) { ?> <p><?php echo $error; ?> </p> <?php } ?> </div> <?php } ?> <form action="<?php echo Toolkit::i()->getRequest()->getUrl(); ?> " method="post" enctype="multipart/form-data" class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label" for="login_field"><?php echo $this->getModel()->fieldTitle('Login'); ?> </label> <div class="col-sm-10"> <?php echo FormHelper::textbox('Login', $this->getModel()->Login); ?> </div> </div>
public function redirect($path, $params = array()) { if (is_array($path)) { $path_real = ''; $cnt = count($path); switch ($cnt) { // this module, controller case 1: $path_real .= $this->sModuleAlias . '/' . $this->sControllerAlias . '/' . $path[0]; break; // this module // this module case 2: $path_real .= $this->sModuleAlias . '/' . implode("/", $path); break; // other // other default: $path_real .= implode("/", $path); } $fullPath = Toolkit::i()->createUrl(strtolower($path_real), $params); header("Location: " . $fullPath); Core::app()->hardEnd(); } else { $fullPath = Toolkit::i()->createUrl(strtolower($path), $params); header("Location: " . $fullPath); Core::app()->hardEnd(); } }
public function pathAssets() { $localPath = dirname(__FILE__) . "/../assets"; return \Toolkit::i()->assetManager->getBasePath() . '/' . \Toolkit::i()->assetManager->generatePath($localPath); }
public function actionLogout($params = array()) { \Toolkit::i()->auth->logout(); header("Location: /"); Core::app()->hardEnd(); }
?> <a class="blog-nav-item" href="<?php echo Toolkit::i()->urlManager->createUrl('app/user/logout'); ?> "><?php echo $this->t('Theme', 'Logout'); ?> (<?php echo Toolkit::i()->auth->getUser()['login']; ?> )</a> <?php } else { ?> <a class="blog-nav-item" href="<?php echo Toolkit::i()->urlManager->createUrl('app/user/login'); ?> "><?php echo $this->t('Theme', 'Login'); ?> </a> <?php } ?> </nav> </div> </div> <div class="container"> <div class="blog-header">
public function createUrl($path, $params = array()) { return Toolkit::i()->urlManager->createUrl($path, $params); }
public function smsEvent($alias, $to, $params = array()) { return Toolkit::i()->smsEvent->raise($alias, $to, $params); }
public function emailEvent($alias, $recipients = array(), $params = array(), $subject = '') { return Toolkit::i()->emailEvent->raise($alias, $recipients, $params, $subject); }
public function getPageUrl($page) { $params = $this->getComponentRequest()->getAnotherParams(); $sort_field = isset($_GET['sort_field']) ? $_GET['sort_field'] : ''; $sort_direction = isset($_GET['sort_direction']) ? $_GET['sort_direction'] : ''; if ($page < 1) { $page = 1; } if ($page != 1) { $params['page'] = $page; } if ($sort_field && $sort_direction) { $params['sort_field'] = $sort_field; $params['sort_direction'] = $sort_direction; } $res = \Toolkit::getInstance()->request->getCleanUrl(); return \Toolkit::i()->urlManager->createUrl($res, $params); }
protected function saveModulesInfo() { return Toolkit::i()->modules->saveModulesInfo(); }