Пример #1
0
 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);
     }
 }
Пример #2
0
 /**
  * Редактирование записи
  *
  * @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()));
 }
Пример #5
0
 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();
 }
Пример #6
0
 public static function getParams()
 {
     return Toolkit::i()->urlManager->getParams();
 }
Пример #7
0
 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);
 }
Пример #8
0
            <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 
Пример #9
0
}
?>
</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>
Пример #10
0
    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>
Пример #11
0
 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();
     }
 }
Пример #12
0
 public function pathAssets()
 {
     $localPath = dirname(__FILE__) . "/../assets";
     return \Toolkit::i()->assetManager->getBasePath() . '/' . \Toolkit::i()->assetManager->generatePath($localPath);
 }
Пример #13
0
 public function actionLogout($params = array())
 {
     \Toolkit::i()->auth->logout();
     header("Location: /");
     Core::app()->hardEnd();
 }
Пример #14
0
    ?>
                <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">
Пример #15
0
 public function createUrl($path, $params = array())
 {
     return Toolkit::i()->urlManager->createUrl($path, $params);
 }
Пример #16
0
 public function smsEvent($alias, $to, $params = array())
 {
     return Toolkit::i()->smsEvent->raise($alias, $to, $params);
 }
Пример #17
0
 public function emailEvent($alias, $recipients = array(), $params = array(), $subject = '')
 {
     return Toolkit::i()->emailEvent->raise($alias, $recipients, $params, $subject);
 }
Пример #18
0
 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);
 }
Пример #19
0
 protected function saveModulesInfo()
 {
     return Toolkit::i()->modules->saveModulesInfo();
 }