public function init() { $this->defaultAttributes = $this->attributes; \Yii::beginProfile("Init: " . $this->className()); $this->initSettings(); \Yii::endProfile("Init: " . $this->className()); }
public function actionIndex() { $this->failIfNotAJsonRpcRequest(); Yii::beginProfile('service.request'); $request = $result = null; try { $request = json_decode(file_get_contents('php://input'), true); $this->failIfRequestIsInvalid($request); try { $class = new ReflectionClass($this->controller); if (!$class->hasMethod($request['method'])) { throw new JsonRpcException("Method not found", -32601); } $method = $class->getMethod($request['method']); ob_start(); Yii::beginProfile('service.request.action'); $result = $method->invokeArgs($this->controller, isset($request['params']) ? $request['params'] : null); Yii::endProfile('service.request.action'); $output = ob_get_clean(); if ($output) { Yii::log($output, CLogger::LEVEL_INFO, 'service.output'); } } catch (Exception $e) { Yii::log($e, CLogger::LEVEL_ERROR, 'service.error'); throw new JsonRpcException($e->getMessage(), -32603); } if (!empty($request['id'])) { echo json_encode(array('jsonrpc' => '2.0', 'id' => $request['id'], 'result' => $output)); } } catch (JsonRpcException $e) { echo json_encode(array('jsonrpc' => '2.0', 'id' => isset($request['id']) ? $request['id'] : null, 'error' => $e->getErrorAsArray())); } Yii::endProfile('service.request'); }
public function actionUpdate($fid = 0, $gid = 0, $sort = '') { $timer = new CountTimer(); $cacheToken = 'cache-update'; Yii::beginProfile($cacheToken); ob_start(); // 生成版块列表缓存 $this->forward('forum/forumlist', false); // 生成帖子列表缓存 $sortArr = array('', 'new', 'marrow', 'top'); $fids = $this->_getFids($fid); $uids = $this->_getUidsByGid($gid); foreach ($sortArr as $sort) { foreach ($fids as $fid) { foreach ($uids as $uid) { $_GET = array_merge($_GET, array('hacker_uid' => $uid, 'boardId' => $fid, 'page' => 1, 'pageSize' => 10, 'sortby' => $sort)); $res = $this->forward('forum/topiclist', false); ob_clean(); } } } ob_end_clean(); var_dump($timer->stop()); Yii::endProfile($cacheToken); }
public function load($filename) { if (!is_readable($filename)) { throw new \yii\base\InvalidValueException('cannot read config file at this location: ' . $filename); } $this->config = Json::decode(file_get_contents($filename), false); \Yii::beginProfile('reflection', 'config'); // // silently injects newly introduced option into current config from default config // $def_config = $this->getDefaultCfg(); $rf1 = new \ReflectionObject($def_config); /* @var $p_base \ReflectionProperty */ foreach ($rf1->getProperties() as $p_base) { // lvl-1: system, book ... $lvl1 = $p_base->name; if (empty($this->config->{$lvl1})) { $this->config->{$lvl1} = $def_config->{$lvl1}; continue; } $rf2 = new \ReflectionObject($def_config->{$p_base->name}); foreach ($rf2->getProperties() as $p_option) { //lvl-2: system->theme .. $lvl2 = $p_option->name; if (empty($this->config->{$lvl1}->{$lvl2})) { $this->config->{$lvl1}->{$lvl2} = $def_config->{$lvl1}->{$lvl2}; continue; //reserved. required for lvl-3 if introduced } } } \Yii::endProfile('reflection', 'config'); }
/** * @param Event $event */ public function combineBundles(Event $event) { if (!$this->enabled) { return; } $token = 'Combine bundles for page'; \Yii::beginProfile($token, __METHOD__); $this->bundles = $this->owner->assetBundles; $this->setAssetManager($this->owner->getAssetManager()); // Assemble monolith assets foreach ($this->bundles as $name => $bundle) { // If this is monolith bundle if (ArrayHelper::getValue($bundle->publishOptions, 'monolith', false)) { // If it already processed and have no dependency if (empty($bundle->depends) && ArrayHelper::getValue($bundle->publishOptions, 'accProcessed', false)) { $this->registerMonolith($bundle); } else { $this->assembleMonolith([$name => $bundle], $bundle->jsOptions, $bundle->cssOptions); } } } // Assemble rest of the assets $this->assembleMonolith($this->bundles); $this->owner->assetBundles = []; \Yii::endProfile($token, __METHOD__); }
/** * @param DataEntityProvider[] $providers * @param ActionData $actionData * @param array $packed * @param array $providedKeys * * @return mixed */ public static function process($providers, &$actionData, &$packed, &$providedKeys) { $result = []; $providedKeys = []; foreach ($providers as $i => $provider) { $profileKey = "DataProviderProcessor: {$i}"; Yii::beginProfile($profileKey); //! @todo Add check for correct class names here /** @var DataEntityProvider $instance */ $instance = Yii::createObject($provider); $providerResult = $instance->getEntities($actionData); $keys = []; array_walk($providerResult, function ($materials, $regionKey) use(&$keys) { $result = []; array_walk($materials, function ($data, $materialIndex) use(&$result) { $result[$materialIndex] = array_keys($data); }); $keys[$regionKey] = $result; }); $providedKeys[$i] = $keys; $result = ArrayHelper::merge($result, $providerResult); $packed[$i] = $instance->pack(); Yii::endProfile($profileKey); } return $result; }
/** * @return string */ public function run() { if (YII_ENV == 'prod') { try { \Yii::beginProfile("Run: " . $this->_token); $content = $this->_run(); \Yii::endProfile("Run: " . $this->_token); } catch (\Exception $e) { $content = \Yii::t('app', 'Error widget {class}', ['class' => $this->className()]) . " (" . $this->descriptor->name . "): " . $e->getMessage(); } } else { \Yii::beginProfile("Run: " . $this->_token); $content = $this->_run(); \Yii::endProfile("Run: " . $this->_token); } \Yii::$app->cmsToolbar->initEnabled(); if (\Yii::$app->cmsToolbar->editWidgets == Cms::BOOL_Y && \Yii::$app->cmsToolbar->enabled) { $pre = ""; /*$pre = Html::tag('pre', Json::encode($this->attributes), [ 'style' => 'display: none;' ]);*/ $id = 'sx-infoblock-' . $this->getId(); $this->getView()->registerJs(<<<JS new sx.classes.toolbar.EditViewBlock({'id' : '{$id}'}); JS ); return Html::tag('div', $pre . (string) $content, ['class' => 'skeeks-cms-toolbar-edit-view-block', 'id' => $id, 'title' => \Yii::t('app', "Double-click on the block will open the settings manager"), 'data' => ['id' => $this->getId(), 'config-url' => $this->getEditUrl()]]); } return $content; }
public function getData() { \Yii::beginProfile('admin-menu'); if ($this->isLoaded) { return (array) $this->groups; } $paths[] = \Yii::getAlias('@common/config/admin/menu.php'); $paths[] = \Yii::getAlias('@app/config/admin/menu.php'); foreach (\Yii::$app->extensions as $code => $data) { if ($data['alias']) { foreach ($data['alias'] as $code => $path) { $adminMenuFile = $path . '/config/admin/menu.php'; if (file_exists($adminMenuFile)) { $menuGroups = (array) (include_once $adminMenuFile); $this->groups = ArrayHelper::merge($this->groups, $menuGroups); } } } } foreach ($paths as $path) { if (file_exists($path)) { $menuGroups = (array) (include_once $path); $this->groups = ArrayHelper::merge($this->groups, $menuGroups); } } ArrayHelper::multisort($this->groups, 'priority'); $this->isLoaded = true; \Yii::endProfile('admin-menu'); return (array) $this->groups; }
private function runProfilingSampleLoop() { Yii::beginProfile('dummy method'); for ($i = 0; $i < 100; $i++) { $a = 1; } Yii::endProfile('dummy method'); }
/** * Returns amount of today comments. * * @return int Number of today comments. * @since 0.1.0 */ public function today() { $token = 'comment.today'; \Yii::beginProfile($token); $dateTime = new \DateTime(); $dateTime->sub(new \DateInterval('P1D')); $amount = (int) $this->count('created >= :today', array(':today' => $dateTime->format(\DateTime::ISO8601))); \Yii::endProfile($token); return $amount; }
/** * @return mixed * @throws Exception */ protected function tryToRunMethod() { $method = $this->getHandler(); Yii::beginProfile('service.request.action'); $output = $this->runMethod($method, $this->getParams($method)); Yii::endProfile('service.request.action'); Yii::info($method, 'service.output'); Yii::info($output, 'service.output'); return $output; }
/** * @param \yii\web\Application $app */ public function bootstrap($app) { if ($app instanceof Application) { $app->response->on(Response::EVENT_AFTER_PREPARE, function (Event $e) use($app) { /** * @var $response Response */ $response = $e->sender; $this->trigger(self::EVENT_BEFORE_PROCESSING); if ($this->enabled && !$app->request->isAjax && !$app->request->isPjax && $app->response->format == Response::FORMAT_HTML) { \Yii::beginProfile('ExternalLinks'); $content = $response->content; $this->initReplaceLinks(); $matches = []; if (preg_match_all("/<[Aa][\\s]{1}[^>]*[Hh][Rr][Ee][Ff][^=]*=[ '\"\\s]*([^ \"'>\\s#]+)[^>]*>/", $content, $matches)) { if (isset($matches[1])) { foreach ($matches[1] as $link) { //Относительные ссылки пропускать if (Url::isRelative($link)) { continue; } if ($dataLink = parse_url($link)) { //Для этого хоста не нужно менять ссылку $host = ArrayHelper::getValue($dataLink, 'host'); if (in_array($host, $this->noReplaceLinksOnDomains)) { continue; } } $linkForUrl = $link; if ($this->enabledB64Encode) { $linkForUrl = base64_encode($link); } $newUrl = Url::to([$this->backendRoute, $this->backendRouteParam => $linkForUrl]); //replacing references only after <body $bodyPosition = strpos($content, '<body'); $headerContent = substr($content, 0, $bodyPosition); $bodyContent = substr($content, $bodyPosition, strlen($content)); $resultContent = ''; $replaceUrl = 'href="' . $newUrl . '"'; $bodyContent = str_replace('href="' . $link . '"', $replaceUrl, $bodyContent); $replaceUrl = 'href=\'' . $newUrl . '\''; $bodyContent = str_replace('href=\'' . $link . '\'', $replaceUrl, $bodyContent); $resultContent = $headerContent . $bodyContent; $content = $resultContent; } } } $response->content = $content; \Yii::endProfile('ExternalLinks'); } }); } }
public function actionIndex() { Yii::beginProfile('wishlist'); $criteria = PropertyWishlistApi::getCriteriaObjectForUser(Yii::app()->user->id); $count = Property::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $properties = PropertyWishlistApi::searchWithCriteria($criteria); // $projects = ProjectWishlistApi::getWishlistProjectsByUserId(Yii::app()->user->id); $this->render('index', array('properties' => $properties, 'count' => $count, 'pages' => $pages)); Yii::endProfile('wishlist'); }
public function actionIndex() { Yii::trace('example trace message', 'example'); Yii::log('info', CLogger::LEVEL_INFO, 'example'); Yii::log('error', CLogger::LEVEL_ERROR, 'example'); Yii::log('trace', CLogger::LEVEL_TRACE, 'example'); Yii::log('warning', CLogger::LEVEL_WARNING, 'example'); Yii::beginProfile('preg_replace', 'example'); for ($i = 0; $i < 10000; $i++) { preg_replace('~^[ a-z]+~', '', 'test it'); } Yii::endProfile('preg_replace', 'example'); echo 'done'; }
protected function createDataArray() { \Yii::beginProfile('createDataArray'); $data = []; Yii::beginProfile('getData'); if (!$this->config['serverSide']) { $paginator = $this->dataProvider->getPagination(); if ($this->dataProvider instanceof \CActiveDataProvider) { $this->dataProvider->criteria->order = ''; } $this->dataProvider->setPagination(false); $source = $this->dataProvider->getData(true); $this->dataProvider->setPagination($paginator); } else { $source = $this->dataProvider->getData(); } Yii::endProfile('getData'); Yii::beginProfile('renderCells'); // Get column name map. $names = array_map([$this, 'getColumnName'], $this->columns); foreach ($source as $i => $r) { $row = []; foreach ($this->columns as $j => $column) { $name = $names[$j]; $row[$name] = $column->getDataCellContent($i); } $metaRow = []; if ($this->addMetaData !== false) { Yii::beginProfile('addMetaData'); if (is_callable([$r, 'getKeyString'])) { $metaRow['data-key'] = call_user_func([$r, 'getKeyString']); } if (is_array($this->addMetaData)) { foreach ($this->addMetaData as $field) { $metaRow["data-{$field}"] = \CHtml::value($r, $field); } } Yii::endProfile('addMetaData'); } if (isset($this->rowCssClassExpression)) { $metaRow['class'] = $this->evaluateExpression($this->rowCssClassExpression, array('row' => $i, 'data' => $r)); } $row['metaData'] = $metaRow; $data[] = $row; } \Yii::endProfile('renderCells'); \Yii::endProfile('createDataArray'); return $data; }
public function actionView($id) { Yii::beginProfile('message_view'); $message = PmbApi::getMessageById($id); if (!$message) { throw new CHttpException(404, 'The requested page does not exist.'); } if ($message->from_user_id != Yii::app()->user->id && $message->to_user_id != Yii::app()->user->id) { $this->redirect('/messages'); } $read = PmbApi::markRead(array($id)); $unread = PmbApi::getUnreadInboxCount(Yii::app()->user->id); $this->render('view', array('message' => $message, 'unread' => $unread, 'id' => $id)); Yii::endProfile('message_view'); }
public function init() { parent::init(); if ($this->module) { // $this->migrateUp(); // $this->loadClassMap(); // $this->loadControllerMap(); // $this->loadViewPathMap(); // $this->loadCustomConfig(); foreach (['loadClassMap', 'loadCustomConfig', 'migrateUp'] as $func) { \Yii::beginProfile(get_called_class() . '->' . $func, __METHOD__); $this->{$func}(); \Yii::endProfile(get_called_class() . '->' . $func, __METHOD__); } } }
public function __toString() { if (!$this->parent instanceof self) { $this->activeForm = CMap::mergeArray($this->defaultActiveFormSettings, $this->activeForm); try { //profile form $profile_id = 'Form::' . $this->activeForm['id']; Yii::beginProfile($profile_id); $res = parent::__toString(); Yii::endProfile($profile_id); return $res; } catch (Exception $e) { Yii::app()->handleException($e); } } }
public function init() { Yii::beginProfile(__CLASS__); $path = Yii::getPathOfAlias('app.widgets.NewsSocials.libs.share42'); $assetsUrl = app()->getAssetManager()->publish($path, FALSE, -1, YII_DEBUG); js($assetsUrl . '/share42.js', CClientScript::POS_END); // Обрезаю description if (!empty($this->params['data-description'])) { $this->params['data-description'] = strip_tags($this->params['data-description']); if (mb_strlen($this->params['data-description']) > $this->charLimit) { $this->params['data-description'] = characterLimiter($this->params['data-description'], $this->charLimit, ' ...'); } } echo CHtml::openTag('div', $this->params + array('class' => 'share42init')) . CHtml::closeTag('div'); Yii::endProfile(__CLASS__); }
/** * Validates JSON-RPC request, initializes controller action parameters and runs the action * @param array $requestData * @return array Controller action response */ protected function processRequest($requestData) { $responseData = ['jsonrpc' => '2.0']; try { $method = ArrayHelper::getValue($requestData, 'method', '-'); \Yii::trace('Running JSON-RPC 2.0 method: ' . $method, 'jsonrpc\\Action::processRequest'); \Yii::beginProfile('jsonrpc.controller.rpc.' . $method); $requestModel = $this->getRequestModel($requestData); $responseData['id'] = $requestModel->id; $reflectionMethod = $this->getControllerMethod($requestModel->method); $methodParams = $this->getMethodParams($reflectionMethod, $requestModel->params); $responseData['result'] = $this->runControllerAction($reflectionMethod->getName(), $methodParams); \Yii::endProfile('jsonrpc.controller.rpc.' . ArrayHelper::getValue($requestData, 'method', '-')); } catch (\Exception $ex) { unset($responseData['result']); $responseData['error'] = ['code' => $ex->getCode(), 'message' => $ex->getMessage(), 'data' => $ex instanceof ValidationException ? $ex->getData() : null]; } return $responseData; }
public function run() { $fileName = Yii::app()->getRuntimePath() . '/banner_stat.dat'; if (!file_exists($fileName)) { // статистики нет return self::RESULT_OK; } $tmpFile = $fileName . ".tmp"; if (file_exists($tmpFile)) { Yii::log('Обнаружен файл "' . $tmpFile . '", возможно, его обработка еще не завершена.', CLogger::LEVEL_ERROR, __CLASS__); return 1; } rename($fileName, $tmpFile); $resultArr = array(); $fp = fopen($tmpFile, "r"); if ($fp) { Yii::beginProfile('aggregate views stat', __CLASS__); while ($data = fgets($fp)) { $data = trim($data); if ($data == "") { continue; } $arr = explode(",", $data); $d = trim($arr[0]); $id = trim($arr[1]); if (array_key_exists($id, $resultArr)) { $resultArr[$id][] = $d; } else { $resultArr[$id] = array($d); } } Yii::beginProfile('aggregate views stat', __CLASS__); } StatView::newViewPacket(Banner::ID_OBJECT, $resultArr, BannerPlace::VIEWING_TYPE_DAY, 'd.m.Y', false); StatView::newViewPacket(Banner::ID_OBJECT, $resultArr, BannerPlace::VIEWING_TYPE_MONTH, 'm.Y', false); StatView::newViewPacket(Banner::ID_OBJECT, $resultArr, BannerPlace::VIEWING_TYPE_ALL, '', false); @unlink($tmpFile); if (file_exists($tmpFile)) { Yii::log("Не удалось удалить временный файл " . $tmpFile, CLogger::LEVEL_WARNING, __CLASS__); } return self::RESULT_OK; }
/** * @brief ESphinxSearchResult constructor * @param array $data * @param objecy $criteria */ public function __construct(array $data, $criteria) { if ($this->enableProfiling) { Yii::beginProfile("Init ESphinxSearchResult", 'CEXT.ESearch.ESphinxSearchResult.init'); } $this->criteria = $criteria; $ar = array(); foreach ($data['matches'] as $id => $data) { $resData = new stdClass(); foreach ($data['attrs'] as $key => $value) { $resData->{$key} = $value; } $resData->id = $id; $resData->_weight = $data['weight']; $ar[$id] = $resData; } $this->setIdList($ar); if ($this->enableProfiling) { Yii::endProfile("Init ESphinxSearchResult", 'CEXT.ESearch.ESphinxSearchResult.init'); } }
public function init() { parent::init(); if ($this->requestIsAdmin()) { if (!$this->noImage) { $this->noImage = AdminAsset::getAssetUrl("images/no-photo.gif"); //$this->noImage = \Yii::$app->getAssetManager()->getAssetUrl(AdminAsset::register(\Yii::$app->view), "images/no-photo.gif"); } \Yii::beginProfile('admin loading'); //Загрузка всех компонентов. $components = \Yii::$app->getComponents(); foreach ($components as $id => $data) { try { \Yii::$app->get($id); } catch (\Exception $e) { continue; } } \Yii::$app->trigger(self::EVENT_READY, new Event(['name' => self::EVENT_READY])); \Yii::endProfile('admin loading'); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { Yii::log("Mi primer log", "info", "application.controllers.SiteController"); Yii::log("eeeeee error", "error", "application.controllers.SiteController"); Yii::log("wwwwwwwwww warning", "warning", "application.controllers.SiteController"); Yii::log("Mi primer trace", "trace", "application.controllers.SiteController"); Yii::log("001#Venta en el sitio tal 1", "info", "application.controllers.SiteController.ref"); Yii::log("003#Venta en el sitio tal 2", "info", "application.controllers.SiteController.ref"); Yii::log("002#Venta en el sitio tal 3", "info", "application.controllers.SiteController.ref"); Yii::beginProfile("miProfileBucleFor", "application.controllers.SiteController"); for ($x = 0; $x < 100; $x++) { echo ""; } Yii::endProfile("miProfileBucleFor", "application.controllers.SiteController"); Yii::beginProfile("miProfileBucleFor", "application.controllers.SiteController"); sleep(1); Yii::endProfile("miProfileBucleFor", "application.controllers.SiteController"); Yii::app()->db->createCommand("SELECT * FROM test")->queryAll(); Test::model()->findAll(); // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('index'); }
private function queryInternal($method, $mode, $params = array()) { $params = array_merge($this->params, $params); if ($this->_connection->enableParamLogging && ($pars = array_merge($this->_paramLog, $params)) !== array()) { $p = array(); foreach ($pars as $name => $value) { $p[$name] = $name . '=' . var_export($value, true); } $par = '. Bound with ' . implode(', ', $p); } else { $par = ''; } if ($this->_connection->queryCachingCount > 0 && $method !== '' && $this->_connection->queryCachingDuration > 0 && $this->_connection->queryCacheID !== false && ($cache = Yii::app()->getComponent($this->_connection->queryCacheID)) !== null) { $this->_connection->queryCachingCount--; $cacheKey = 'yii:dbquery' . $this->_connection->connectionString . ':' . $this->_connection->username; $cacheKey .= ':' . $this->getText() . ':' . serialize(array_merge($this->_paramLog, $params)); if (($result = $cache->get($cacheKey)) !== false) { return $result[0]; } } try { if ($this->_connection->enableProfiling) { Yii::beginProfile('system.db.CDbCommand.query(' . $this->getText() . $par . ')', 'system.db.CDbCommand.query'); } $this->prepare(); if ($params === array()) { $this->_statement->execute(); } else { $this->_statement->execute($params); } if ($method === '') { $result = new CDbDataReader($this); } else { $mode = (array) $mode; call_user_func_array(array($this->_statement, 'setFetchMode'), $mode); $result = $this->_statement->{$method}(); $this->_statement->closeCursor(); } if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . $par . ')', 'system.db.CDbCommand.query'); } if (isset($cache, $cacheKey)) { $cache->set($cacheKey, array($result), $this->_connection->queryCachingDuration, $this->_connection->queryCachingDependency); } return $result; } catch (Exception $e) { if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . $par . ')', 'system.db.CDbCommand.query'); } $errorInfo = $e instanceof PDOException ? $e->errorInfo : null; $message = $e->getMessage(); Yii::log(Yii::t('yii', 'CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.', array('{method}' => $method, '{error}' => $message, '{sql}' => $this->getText() . $par)), CLogger::LEVEL_ERROR, 'system.db.CDbCommand'); if (YII_DEBUG) { $message .= '. The SQL statement executed was: ' . $this->getText() . $par; } throw new CDbException(Yii::t('yii', 'CDbCommand failed to execute the SQL statement: {error}', array('{error}' => $message)), (int) $e->getCode(), $errorInfo); } }
<?php //$this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs)) ?> <div class="clearfix"> <div class="btn-toolbar pull-left"> <div class="btn-group"> <h1> <i class="icon-file-text-alt"></i> <?php echo Yii::t('D2finvModule.model', 'Finv Invoices'); ?> </h1> </div> <div class="btn-group"> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('D2finvModule.crud_static', 'Incoming'), 'icon' => 'icon-plus', 'size' => 'large', 'type' => 'success', 'url' => array('create', 'finv_type' => FinvInvoice::FINV_TYPE_IN), 'visible' => Yii::app()->user->checkAccess('D2finv.FinvInvoice.*') || Yii::app()->user->checkAccess('D2finv.FinvInvoice.Create'), "htmlOptions" => array("data-toggle" => "tooltip", "title" => Yii::t("TrucksModule.crud", "Create Incoming Invoice")))); $this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('D2finvModule.crud_static', 'Outgoing'), 'icon' => 'icon-plus', 'size' => 'large', 'type' => 'success', 'url' => array('create', 'finv_type' => FinvInvoice::FINV_TYPE_OUT), 'visible' => Yii::app()->user->checkAccess('D2finv.FinvInvoice.*') || Yii::app()->user->checkAccess('D2finv.FinvInvoice.Create'), "htmlOptions" => array("data-toggle" => "tooltip", "title" => Yii::t("TrucksModule.crud", "Create Outgoing Invoice")))); ?> </div> </div> </div> <?php Yii::beginProfile('FinvInvoice.view.grid'); ?> <?php $this->widget('TbGridView', array('id' => 'finv-invoice-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{summary}{pager}{items}{pager}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'finv_number', 'editable' => array('url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'finv_ccmp_id', 'value' => 'CHtml::value($data, \'finvCcmp.itemLabel\')', 'filter' => CHtml::listData(CcmpCompany::model()->findAll(array('limit' => 1000, 'order' => 'ccmp_name')), 'ccmp_id', 'itemLabel'), 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'), 'source' => CHtml::listData(CcmpCompany::model()->findAll(array('limit' => 1000)), 'ccmp_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'finv_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver')), 'filter' => $this->widget('vendor.dbrisinajumi.DbrLib.widgets.TbFilterDateRangePicker', array('model' => $model, 'attribute' => 'finv_date_range', 'options' => array('ranges' => array('today', 'yesterday', 'this_week', 'last_week', 'this_month', 'last_month', 'this_year'))), TRUE)), array('htmlOptions' => array('class' => 'numeric-column'), 'name' => 'finv_amt', 'footer' => $model->getTotals('finv_amt'), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('htmlOptions' => array('class' => 'numeric-column'), 'name' => 'finv_vat', 'footer' => $model->getTotals('finv_vat'), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('htmlOptions' => array('class' => 'numeric-column'), 'name' => 'finv_total', 'footer' => $model->getTotals('finv_total'), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('class' => 'editable.EditableColumn', 'name' => 'finv_stst_id', 'value' => 'CHtml::value($data, \'finvStst.itemLabel\')', 'filter' => CHtml::listData(StstState::model()->findAll(array('limit' => 1000)), 'stst_id', 'itemLabel'), 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'), 'source' => CHtml::listData(StstState::model()->findAll(array('limit' => 1000)), 'stst_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'finv_paid', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'), 'source' => $model->getEnumFieldLabels('finv_paid')), 'filter' => $model->getEnumFieldLabels('finv_paid')), array('class' => 'TbButtonColumn', 'template' => '{view} {update} {delete} {copy}', 'buttons' => array('view' => array('visible' => '!Yii::app()->user->checkAccess("InvoiceEdit")'), 'update' => array('visible' => 'Yii::app()->user->checkAccess("InvoiceEdit")'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("InvoiceEdit")'), 'copy' => array('label' => Yii::t('D2finvModule.crud_static', 'Copy'), 'icon' => 'copy', 'url' => 'Yii::app()->controller->createUrl("copy", array("finv_id" => $data->finv_id))', 'visible' => 'Yii::app()->user->checkAccess("InvoiceEdit")')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("finv_id" => $data->finv_id))', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("view", array("finv_id" => $data->finv_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("finv_id" => $data->finv_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'updateButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'))))); Yii::endProfile('FinvInvoice.view.grid');
<?php $this->setPageTitle(Yii::t('EdifactDataModule.model', 'Containers')); ?> <div class="clearfix"> <div class="btn-toolbar pull-left"> <div class="btn-group"> <h1> <i class="icon-th-large"></i> <?php echo Yii::t('EdifactDataModule.model', 'Containers'); ?> </h1> </div> </div> </div> <?php Yii::beginProfile('EcprContainerProcesing.view.grid'); $this->widget('TbGridView', array('id' => 'ecpr-container-procesing-grid', 'dataProvider' => $model->searchExt(), 'filter' => $model, 'template' => '{items}{pager}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('name' => 'ecnt_terminal', 'type' => 'raw', 'value' => 'Chtml::tag("span" , array("class" => $data->getTerminalClass() ), $data->ecnt_terminal)'), array('name' => 'ecnt_container_nr'), array('name' => 'ecnt_statuss'), array('name' => 'ecnt_length', 'htmlOptions' => array('class' => 'numeric-column')), array('name' => 'ecnt_datetime'), array('name' => 'action_amt', 'htmlOptions' => array('class' => 'numeric-column')), array('name' => 'time_amt', 'htmlOptions' => array('class' => 'numeric-column')), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'Yii::app()->user->checkAccess("Edifactdata.EcprContainerProcesing.View")'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'FALSE')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("ecpr_id" => $data->ecpr_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("ecpr_id" => $data->ecpr_id))', 'deleteConfirmation' => Yii::t('`crud', 'Do you want to delete this item?'), 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'))))); Yii::endProfile('EcprContainerProcesing.view.grid');
/** * @param ActiveDataProvider $activeDataProvider */ public function search(ActiveDataProvider $activeDataProvider, $tableName = 'cms_content_element') { $classSearch = $this->propertyElementClassName; /** * @var $activeQuery ActiveQuery */ $activeQuery = $activeDataProvider->query; $elementIdsGlobal = []; $applyFilters = false; foreach ($this->toArray() as $propertyCode => $value) { //TODO: add to validator related properties if ($propertyCode == 'properties') { continue; } if ($property = $this->getProperty($propertyCode)) { if ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_NUMBER) { $elementIds = []; $query = $classSearch::find()->select(['element_id'])->where(["property_id" => $property->id])->indexBy('element_id'); if ($fromValue = $this->{$this->getAttributeNameRangeFrom($propertyCode)}) { $applyFilters = true; $query->andWhere(['>=', 'value_num', (double) $fromValue]); } if ($toValue = $this->{$this->getAttributeNameRangeTo($propertyCode)}) { $applyFilters = true; $query->andWhere(['<=', 'value_num', (double) $toValue]); } if (!$fromValue && !$toValue) { continue; } $elementIds = $query->all(); } else { if (!$value) { continue; } $applyFilters = true; if ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_STRING) { $elementIds = $classSearch::find()->select(['element_id'])->where(["property_id" => $property->id])->andWhere(['like', 'value', $value])->indexBy('element_id')->all(); } else { $elementIds = $classSearch::find()->select(['element_id'])->where(["value" => $value, "property_id" => $property->id])->indexBy('element_id')->all(); } } $elementIds = array_keys($elementIds); \Yii::beginProfile('array_intersect'); if (!$elementIds) { $elementIdsGlobal = []; } if ($elementIdsGlobal) { $elementIdsGlobal = array_intersect($elementIds, $elementIdsGlobal); } else { $elementIdsGlobal = $elementIds; } \Yii::endProfile('array_intersect'); } } if ($applyFilters) { $activeQuery->andWhere([$tableName . '.id' => $elementIdsGlobal]); } }
/** * @param string method of PDOStatement to be called * @param mixed the first parameter to be passed to the method * @param array input parameters (name=>value) for the SQL execution. This is an alternative * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing * them in this way can improve the performance. Note that you pass parameters in this way, * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa. * binding methods and the input parameters this way can improve the performance. * This parameter has been available since version 1.0.10. * @return mixed the method execution result */ private function queryInternal($method, $mode, $params = array()) { if ($this->_connection->enableParamLogging && ($pars = array_merge($this->_params, $params)) !== array()) { $p = array(); foreach ($pars as $name => $value) { $p[$name] = $name . '=' . $value; } $par = '. Bind with parameter ' . implode(', ', $p); } else { $par = ''; } Yii::trace('Querying SQL: ' . $this->getText() . $par, 'system.db.CDbCommand'); try { if ($this->_connection->enableProfiling) { Yii::beginProfile('system.db.CDbCommand.query(' . $this->getText() . ')', 'system.db.CDbCommand.query'); } $this->prepare(); if ($params === array()) { $this->_statement->execute(); } else { $this->_statement->execute($params); } if ($method === '') { $result = new CDbDataReader($this); } else { $result = $this->_statement->{$method}($mode); $this->_statement->closeCursor(); } if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . ')', 'system.db.CDbCommand.query'); } return $result; } catch (Exception $e) { if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . ')', 'system.db.CDbCommand.query'); } Yii::log('Error in querying SQL: ' . $this->getText() . $par, CLogger::LEVEL_ERROR, 'system.db.CDbCommand'); $errorInfo = $e instanceof PDOException ? $e->errorInfo : null; throw new CDbException(Yii::t('yii', 'CDbCommand failed to execute the SQL statement: {error}', array('{error}' => $e->getMessage())), (int) $e->getCode(), $errorInfo); } }
/** * Manipulation with media image * For example, * * ~~~ * $Media = Media::find(); * $src = $Media->image()->thumbnail(150, 150)->frame(5)->export(); * * echo Html::img($src); * ~~~ * * @return \cookyii\modules\Media\ImageWrapper * @throws \Exception */ public function image() { \Yii::beginProfile(sprintf('manipulating with file `%s`', $this->id), 'Media\\Manipulation'); $result = null; if ($this->isImage()) { $result = \Yii::createObject(['class' => \cookyii\modules\Media\ImageWrapper::class, 'Media' => $this]); } else { $result = \Yii::createObject(['class' => \cookyii\modules\Media\ImageWrapper::class, 'Media' => static::getPlaceholder()]); } return $result; }