public function render() { $value = 0; $value_id = 0; $oDataProvider = new DataProvider($this->getDataSource()); $oData = $oDataProvider->execute(); //echo '<pre>', print_r($oData, true), '</pre>'; die(); $aResult = array(); /*$aResult[] = array( 'Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue() ); */ if ($this->getDefault()) { $aRs = array(); if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) { $value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET); } } //echo 'val:', print_r($this->getValue()->toSimpleArray(), true); if ($this->getValue()) { $value_id = $this->getValue()->toSimpleArray(); } if ($oData->count() > 0) { foreach ($oData as $itm) { $getter = 'get' . $this->getValueField(); $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat()); $aRs = array(); if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) { foreach ($aRs[1] as $k => $val) { $value = $itm; if (strpos($val, "-") !== false) { $xVal = explode("-", $val); foreach ($xVal as $_val) { $sGetter = 'get' . $_val; $value = call_user_func(array($value, $sGetter)); } } else { $sGetter = 'get' . $val; $value = call_user_func(array($value, $sGetter)); } $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']); } } /*if (isset($aContainer['IsTree']) && $aContainer['IsTree'] == true) { $aResultTmp['Name'] = str_repeat(' |-- ', $itm->getTreeLevel() - 1).$aResultTmp['Name']; }*/ $aResult[] = $aResultTmp; } } $sResult = FormHelper::multiselect($this->getAlias() . '[]', $value_id, $aResult, array('class' => 'multiselect', 'id' => 'field_' . $this->getAlias())); if ($this->getExtended()) { $sResult .= '<script>$(document).ready( function() { $(\'#field_' . $this->getAlias() . '\').multiselect({sortable: false, searchable: false}); } );</script>'; } echo $sResult; }
public function render() { $value = 0; $value_id = 0; $aDataSource = $this->getDataSource(); $aDataSource[2]['Criteria']['ParentId'] = 0; $oDataProvider = new DataProvider($aDataSource); $oData = $oDataProvider->execute(); //echo '<pre>', print_r($oData, true), '</pre>'; die(); $aResult = array(); $aResult[] = array('Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue()); if ($this->getDefault()) { $aRs = array(); if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) { $value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET); } } if ($this->getValue()) { $value_id = $this->getValue(); } if ($oData->count() > 0) { $aResult = $this->getChilds($oData, 1, $aResult); } echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox', 'id' => 'field_' . $this->getAlias())); }
public function render() { $value = 0; $value_id = 0; $aDataSource = $this->getDataSource(); if ($this->getIsTree()) { $aDataSource[2]['Criteria']['ParentId'] = 0; } $oDataProvider = new DataProvider($aDataSource); $oData = $oDataProvider->execute(); //echo '<pre>', print_r($oData, true), '</pre>'; die(); $aResult = array(); $aResult[] = array('Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue()); if ($this->getDefault()) { $aRs = array(); if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) { $value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET); } } if ($this->getValue()) { $value_id = $this->getValue(); } $aResult = $this->createRow($oData, $aResult); if ($this->getOnChange()) { $tmpChange = $this->getOnChange(); echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox ajax_response_list', 'data-field' => $tmpChange[0], 'data-id' => $this->getValue(), 'id' => 'field_' . $this->getAlias())); //$.post('/structure/page_backend/typeParams', {Id: $this->getValue()}, function (data) { /* response */ }); } else { echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox', 'id' => 'field_' . $this->getAlias())); } }
public function run() { $this->start(); $aResult = array(); $aData = array(); $oData = $this->getComponentRequest()->getData(); $buttons = $this->getComponentRequest()->getButtons(); foreach ($this->getComponentRequest()->getFields() as $alias => $header) { $sClassName = $this->sModuleAlias . 'FormView' . $header['Type'] . 'Column'; $aTmpParams2 = array('Module' => $this->sModuleAlias, 'Component' => $this->sComponentAlias, 'Alias' => $alias, 'Type' => $header['Type'], 'Help' => isset($header['Help']) ? $header['Help'] : '', 'Title' => $header['Title'], 'Required' => isset($header['Params']['Required']) ? $header['Params']['Required'] : false); if (isset($header['Field'])) { if (is_object($oData)) { $sGetter = 'get' . $header['Field']; $aTmpParams2['Value'] = call_user_func(array($oData, $sGetter)); } else { if (is_array($oData)) { if (!empty($oData[$header['Field']])) { $aTmpParams2['Value'] = $oData[$header['Field']]; } else { $aTmpParams2['Value'] = ''; } } } } if (isset($header['Params']) && count($header['Params'])) { $aTmpParams2 = \ArrayHelper::merge($aTmpParams2, $header['Params']); } $aData[$alias] = new $sClassName($aTmpParams2); } $backLink = $this->getComponentRequest()->getBackLink(); if ($backLink) { $aRs = array(); if (preg_match_all("#:~(.*?)#isU", $backLink, $aRs)) { foreach ($aRs[0] as $k => $it) { $backLink = str_replace($it, Toolkit::getInstance()->request->get($aRs[1][$k], Request::C_GET), $backLink); } } if (preg_match_all("#:(.*?)#isU", $backLink, $aRs)) { foreach ($aRs[0] as $k => $it) { $sGetter = 'get' . $aRs[1][$k]; $backLink = str_replace($it, call_user_func(array($oData, $sGetter)), $backLink); } } } if (!empty($buttons)) { $aResult['Buttons'] = new \SimpleCollection(); foreach ($buttons as $button) { $aResult['Buttons']->add(new \RuxonFormViewButton($button)); } } $aResult['ElementId'] = is_object($oData) ? $oData->getId() : 0; $aResult['Title'] = $this->getComponentRequest()->getTitle(); $aResult['Errors'] = $this->getComponentRequest()->getErrors(); $aResult['BackLink'] = $backLink; $aResult['Data'] = new \SimpleCollection($aData); $this->end($aResult, true); }
public function run(FilterChain $oFilterChain) { if (Toolkit::getInstance()->auth->checkAdminAccess()) { $oFilterChain->next(); } else { header("Location: " . Toolkit::getInstance()->auth->loginUrl); Core::app()->hardEnd(); } }
public function run(FilterChain $oFilterChain) { if (count($this->getParams())) { foreach ($this->getParams() as $key => $val) { $class_name = $val['class']; unset($val['class']); Toolkit::getInstance()->addToolkit($key, new $class_name($val)); } } $oFilterChain->next(); }
public function raise($alias, $recipients, $params = array()) { Loader::import('Modules.Main'); if (!is_array($recipients)) { $recipients = array($recipients); } $event = Manager::getInstance()->getMapper('EmailObjectMapper')->findFirst(array('Criteria' => array('IsActive' => true, 'Alias' => $alias))); if ($event->getId()) { Toolkit::getInstance()->mail->ClearAddresses(); Toolkit::getInstance()->mail->From = Manager::getInstance()->getModule('Main')->config('FromEmail'); Toolkit::getInstance()->mail->FromName = Manager::getInstance()->getModule('Main')->config('FromName'); foreach ($recipients as $email) { Toolkit::getInstance()->mail->AddAddress($email); } Toolkit::getInstance()->mail->Subject = $event->getSubject(); $emailTemplate = new MailTemplate($params); Toolkit::getInstance()->mail->SetHtmlBody($emailTemplate->fetch($event->getAlias())); return Toolkit::getInstance()->mail->Send(); } return false; }
public function init() { if (!$this->merchant_id) { $this->merchant_id = Manager::getInstance()->getModule('Shop')->config('PlatronMerchantId'); } if (!$this->secret_key) { $this->secret_key = Manager::getInstance()->getModule('Shop')->config('PlatronSecretKey'); } if ($this->test_mode === null) { $this->test_mode = Manager::getInstance()->getModule('Shop')->config('PlatronTestMode'); } if (!$this->site_url) { $this->site_url = 'http://' . Toolkit::getInstance()->request->getServerName(); } if (!$this->result_url) { $this->result_url = 'http://' . Toolkit::getInstance()->request->getServerName() . '/shop/payment/result'; } if (!$this->success_url) { $this->success_url = 'http://' . Toolkit::getInstance()->request->getServerName() . '/shop/payment/success'; } if (!$this->failure_url) { $this->failure_url = 'http://' . Toolkit::getInstance()->request->getServerName() . '/shop/payment/failed'; } }
/** * Возвращает тулкит * * @return Toolkit */ protected function getToolkit() { return Toolkit::getInstance(); }
foreach ($this->getErrors() as $error) { ?> <p><?php echo $error; ?> </p> <?php } ?> </div> <?php } ?> <form action="<?php echo Toolkit::getInstance()->getRequest()->getUrl(); ?> " method="post" enctype="multipart/form-data" class="form-horizontal"> <?php foreach ($this->getData() as $field) { ?> <div class="form-group"> <label class="col-sm-2 control-label" for="field_<?php echo $field->getAlias(); ?> "><?php echo $field->getTitle(); if ($field->getRequired()) { ?> <span class="required">*</span><?php
protected function executeRequest($nStatusCode, $aParams) { $sModule = $aParams['Module']; $sController = 'ruxon\\modules\\' . $sModule . '\\controllers\\' . $aParams['Controller'] . 'Controller'; $sAction = $aParams['Action']; Core::import('Modules.' . $sModule); if (!class_exists($sController)) { $sController = $aParams['Controller'] . 'Controller'; } Core::app()->theme()->getLayout()->setMetaTitle($aParams['Action'] . ' - ' . $aParams['Controller'] . ' - ' . $aParams['Module']); $oController = new $sController($sModule, $aParams['Controller']); unset($aParams['Action']); unset($aParams['Controller']); unset($aParams['Module']); $oResult = $oController->run($sAction, $aParams); Core::app()->response()->setStatus($nStatusCode); if (is_object($oResult)) { if ($oResult->getLayout()) { Core::app()->theme()->getLayout()->setContent($oResult->getHtml()); $fullcontent = Core::app()->theme()->fetch(); Core::app()->response()->setResponseText($fullcontent); } else { $res = Toolkit::getInstance()->client->renderAjaxScriptFiles(); $res .= Toolkit::getInstance()->client->renderAjaxCssFiles(); Core::app()->response()->setResponseText($res . $oResult->getHtml()); } } return true; }
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); }
public function refresh() { Toolkit::getInstance()->response->refresh(); }
public function getFileUrl() { return Toolkit::getInstance()->fileStorage->bucket($this->bucket)->getUrl() . '/' . $this->path; }
public function getUserRatingData() { $categoryId = $this->getOwner()->getRatingId(); $mapper = Manager::getInstance()->getMapper($this->mapper_alias); return $mapper->find(array('Criteria' => array('user_modification_id' => Toolkit::getInstance()->auth->getUserId(), 'CategoryId' => $categoryId))); }
public function refresh() { $this->addHeader('Location', Toolkit::getInstance()->request->getUrl()); $this->sendHeaders(); exit; }
public function getToolkit() { return Toolkit::getInstance(); }
public static function toolkit() { return Toolkit::getInstance(); }
public function getHeight() { $image_info = getimagesize(Toolkit::getInstance()->fileStorage->bucket($this->bucket)->getPath() . '/' . $this->path); return intval($image_info[1]); }
/** * getUserId * * @static * @access public * @return void */ static function getUserId() { $_this =& Toolkit::getInstance(); $user = $_this->user(); return Set::extract($user, 'User.id'); }
public function actionUpload($aParams = array()) { $upload = new UploadHandler(array('upload_dir' => Toolkit::getInstance()->fileStorage->bucket('images')->getPath() . '/', 'upload_url' => Toolkit::getInstance()->fileStorage->bucket('images')->getUrl() . '/', 'script_url' => Toolkit::getInstance()->request->getUrl(), 'accept_file_types' => '/\\.(gif|jpe?g|png|swf)$/i')); Core::app()->hardEnd(); //return $this->view('Index'); }
public function checkActionAccess($action, $params = false) { $aConfig = $this->config($action); // Проверка доступа if (!empty($aConfig['Access'])) { $bAllow = false; foreach ($aConfig['Access'] as $access) { if (Toolkit::getInstance()->auth->checkAccess($access, $params)) { $bAllow = true; break; } } if (!$bAllow) { echo 'Доступа нет'; exit; } } }