protected function afterValidate() { $highlighter = new CTextHighlighter(); $highlighter->language = $this->language; $this->html = $highlighter->highlight($this->code); return parent::afterValidate(); }
/** * Displays a particular model. * * @param integer $id the ID of the model to be displayed * * @return void */ public function actionView($id) { $model = $this->loadModel($id); $code = "<?php \$this->widget(\n\t\"application.modules.contentblock.widgets.ContentBlockWidget\",\n\tarray(\"code\" => \"{$model->code}\"));\n?>"; $highlighter = new CTextHighlighter(); $highlighter->language = 'PHP'; $example = $highlighter->highlight($code); $this->render('view', ['model' => $model, 'example' => $example]); }
/** * Отображает меню по указанному идентификатору * @param integer $id Идинтификатор меню для отображения */ public function actionView($id) { $model = $this->loadModel($id); $code = "<?php \$this->widget(\n 'application.modules.menu.widgets.MenuWidget', array(\n 'name' => '{$model->code}',\n 'params' => array('hideEmptyItems' => true),\n 'layoutParams' => array(\n 'htmlOptions' => array(\n 'class' => 'jqueryslidemenu',\n 'id' => 'myslidemenu',\n )\n ),\n )\n); ?>"; $highlighter = new CTextHighlighter(); $highlighter->language = 'PHP'; $example = $highlighter->highlight($code); $this->render('view', array('model' => $model, 'example' => $example)); }
public static function xmlDump($var) { $oDM = new DOMDocument(); $oDM->loadXML($var); if ($oDM) { $oDM->formatOutput = true; $oDM->normalize(); $var = $oDM->saveXML(); $widget = new CTextHighlighter(); $widget->language = 'xml'; echo $widget->highlight(${$var}); } }
public function getBodyHtml() { $highlighter = new CTextHighlighter(); $highlighter->language = 'php'; //$highlighter->showLineNumbers = true; $html = $this->body_html; $replacements = array(); preg_match_all('/<\\?php.*?\\?>/imus', $html, $matches); foreach ($matches[0] as $match) { $match = trim($match); $replacements['{' . md5(key($replacements) . microtime()) . '}'] = $highlighter->highlight($match); $html = str_replace($match, key($replacements), $html); } preg_match_all('/<code>(.*?)<\\/code>/imus', $html, $matches); foreach ($matches[1] as $match) { $match = trim($match); $replacements['{' . md5(key($replacements) . microtime()) . '}'] = $highlighter->highlight($match); $html = str_replace($match, key($replacements), $html); } //var_dump($replace); /* Emphasized Text */ //$html = preg_replace('!<code>(.*?)</code>!imus', '<code>$1</code>', $html); // Normalize Newlines $html = str_replace("\r", "\n", $html); $html = preg_replace("!\n\n+!", "\n", $html); // Escaped (Safe) by Default //$html = htmlentities($html, ENT_QUOTES, 'UTF-8'); // Make Paragraphs $lines = explode("\n", $html); foreach ($lines as $key => $line) { $lines[$key] = "<p>{$line}</p>"; } $html = implode("\n", $lines); foreach ($replacements as $key => $replace) { $replace = wordwrap($replace); $html = str_replace($key, $replace, $html); } // Replace links //$pattern = '/(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)/i'; /*$pattern = '/(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?/'; $replacement = '<a href="\\0">\\0</a>'; $html = preg_replace($pattern, $replacement, $html); var_dump(preg_replace($pattern, $replacement, $html)); */ // Strip tags //$html = strip_tags($html, '<p><a><em><strong><cite><code><ul><ol><li><dl><dt><dd><pre><span>'); return $html; }
public function actionGetInfo($id) { $model = GdsRequest::model()->findByPk(new MongoID($id)); $retArr = array(); $widget = new CTextHighlighter(); $widget->language = 'xml'; $retArr['methodName'] = $model->methodName; $retArr['requestXml'] = $widget->highlight($model->requestXml); $retArr['responseXml'] = $widget->highlight($model->responseXml); $retArr['timestamp'] = date("Y-m-d H:i:s", $model->timestamp); $retArr['executionTime'] = Yii::app()->format->formatNumber($model->executionTime); $retArr['errorDescription'] = $model->errorDescription; //$retArr['responseXml'] = $model->responseXml; //echo $model->requestXml); echo json_encode($retArr); die; }
public function actionGetInfo($id) { $model = PaymentLog::model()->findByPk(new MongoID($id)); $retArr = array(); $widget = new CTextHighlighter(); $widget->language = 'javascript'; $retArr['methodName'] = $model->methodName; $retArr['request'] = $widget->highlight($this->prettyJson($model->request)); if ($model->response) { $retArr['response'] = $widget->highlight($this->prettyJson($model->response)); } $retArr['timestamp'] = date("Y-m-d H:i:s", $model->timestamp); $retArr['executionTime'] = Yii::app()->format->formatNumber($model->executionTime); $retArr['errorDescription'] = $model->errorDescription; //$retArr['responseXml'] = $model->responseXml; //echo $model->requestXml); echo json_encode($retArr); exit; }
public function actionGetInfo($id) { $model = GdsRequest::model()->findByPk(new MongoID($id)); $retArr = array(); $widget = new CTextHighlighter(); $widget->language = 'xml'; $retArr['methodName'] = $model->methodName; $retArr['requestXml'] = $widget->highlight($model->requestXml); if (strlen($model->responseXml) < 7500) { $retArr['responseXml'] = $widget->highlight($model->responseXml); } else { $retArr['responseXml'] = '<pre>' . htmlspecialchars(UtilsHelper::formatXML($model->responseXml)) . '</pre>'; } $retArr['timestamp'] = date("Y-m-d H:i:s", $model->timestamp); $retArr['executionTime'] = Yii::app()->format->formatNumber($model->executionTime); $retArr['errorDescription'] = $model->errorDescription; //$retArr['responseXml'] = $model->responseXml; //echo $model->requestXml); echo json_encode($retArr); die; }
public function actionGetCode($attributes = array(), $preview = true) { if (!$attributes) { $attributes = $_POST['Model']; } try { $params = array_merge($attributes, array('rules' => "", "constants" => array())); $meta = Yii::app()->db->createCommand("SHOW FUll columns FROM " . $params['table'])->queryAll(); $params['meta'] = $meta; $length = array(); foreach ($meta as $data) { if (preg_match("|enum\\((.*)\\)|", $data['Type'], $values)) { $constants = array(); $values = explode(',', $values[1]); foreach ($values as $value) { $value = trim($value, "'"); $constants[] = strtoupper($data['Field']) . '_' . strtoupper($value) . " = '{$value}'"; } $params['constants'][$data['Field']] = $constants; } } $params['rules'] .= $this->addRequiredRules($meta); $params['rules'] .= $this->addLengthRules($meta); $params['rules'] .= $this->addInRangeRules($meta); $params['rules'] .= $this->addUniqueRules($meta); $params['rules'] .= $this->addNumericalRules($meta); $params['rules'] .= $this->addCoreValidatorRules($meta); $code = $this->renderPartial('codegen.views.templates.model', $params, true); //file_put_contents($_SERVER['DOCUMENT_ROOT'] . 'model.php', $code); if ($preview) { $highlighter = new CTextHighlighter(); $highlighter->language = 'php'; echo $highlighter->highlight($code); } else { return $code; } } catch (CException $e) { echo $e->getMessage(); } }
<?php $this->pageTitle = Yii::t('auth', 'Users Auth Assignment'); $this->breadcrumbs = array(Yii::t("auth", "Access Control") => array('hrbacitem/index'), Yii::t("auth", "Users Auth Assignment")); $this->menu = array(array('label' => Yii::t('auth', 'Assign Auth'), 'url' => array('assign', 'userid' => $data['userid'])), array('label' => ' '), array('label' => ' '), array('label' => Yii::t('auth', 'Create Auth Item'), 'url' => array('create')), array('label' => Yii::t('auth', 'Assign Auth Item'), 'url' => array('assign')), array('label' => 'List Auth Items', 'url' => array('hrbacitem/index')), array('label' => 'User Permissions', 'url' => array('hrbacuser/list'))); echo "<h2>Auth Assignments to '{$data['username']}'</h2>"; $type = array('Operation', 'Op Group', 'Role'); $syntaxHighlighter = new CTextHighlighter(); $syntaxHighlighter->language = 'PHP'; foreach ($data['auths'] as $auth) { $name = $auth['alt_name'] ? $auth['alt_name'] : $auth['name']; echo '<div class="view">'; echo '<b>Auth:</b> ' . CHtml::link(CHtml::encode($name), array('viewitem', 'userid' => $data['userid'], 'itemid' => $auth['auth_id'])); echo '<br><b>Type:</b> ' . $type[$auth['type']]; if ($auth['description']) { echo '<br><b>Description:</b> ' . $auth['description']; } if ($auth['cond']) { echo '<br><b>Condition:</b> ' . $auth['cond']; } if ($auth['bizrule']) { echo '<br><b>PHP Rule:</b> ' . $syntaxHighlighter->highlight($auth['bizrule']); } echo '</div>'; } ?> <div class="view"> <b>All Roles, Op Groups and Ops directly or indirectly assigned to this user:</b> <br/> <?php
/** * Registers the needed CSS file. * @param string $url the CSS URL. If null, a default CSS URL will be used. */ public static function registerCssFile($url = null) { CTextHighlighter::registerCssFile($url); }
public function actionGetRequestInfo($className, $keyName, $key) { $requestModel = EMongoDocument::model($className)->findByAttributes(array($keyName => $key)); $retArr = array(); $widget = new CTextHighlighter(); $widget->language = 'xml'; $retArr['methodName'] = $requestModel->methodName; $retArr['requestXml'] = $widget->highlight($requestModel->requestXml); $retArr['responseXml'] = $widget->highlight($requestModel->responseXml); //$retArr['requestUrl'] = $requestModel->requestUrl; $retArr['timestamp'] = date("Y-m-d H:i:s", $requestModel->timestamp); $retArr['executionTime'] = Yii::app()->format->formatNumber($requestModel->executionTime); $retArr['errorDescription'] = $requestModel->errorDescription; echo json_encode($retArr); die; }
/** * this method prepares the sections on the bar */ public function prepareBars() { foreach ($this->bar as &$bar) { $result = false; switch ($bar['content']) { case self::BAR_DB: // if $html == self::BAR_DB CTextHighlighter::registerCssFile(); $driver = Yii::app()->db->getDriverName(); $result = CHtml::tag('span', array('class' => 'qtzDBPoint'), Yii::t('QtzPanel.app', '{driver}: unknown info.', array('{driver}' => $driver))); break; case self::BAR_MEMORY: // if $html == self::BAR_MEMORY $result = Yii::t('QtzPanel.app', 'Usage memory: <span class="qtzMemoryPoint">unknown</span> Mb'); break; case self::BAR_EXECUTION_TIME: // if $html == self::BAR_EXECUTION_TIME $result = Yii::t('QtzPanel.app', 'Execution time: <span class="qtzTimePoint">unknown</span> s.'); break; case self::BAR_LOGS: // if $html == self::BAR_LOGS $result = Yii::t('QtzPanel.app', 'Show logs'); break; default: $result = $bar['content']; break; } $bar['content'] = $result; } }
if ($index == 0) { echo "<td rowspan='{$authCount}'>" . CHtml::link(CHtml::encode($user['username']), array("viewuser", "userid" => $user['userid'])) . "</td>"; } echo "<td>" . $type[$auth['type']] . "</td>"; echo "<td>"; // echo CHtml::link(CHtml::encode($auth['name']),array("hrbacuser/edituser","user"=>$auth['name'])) ; echo CHtml::link(CHtml::encode($auth['alt_name'] ? $auth['alt_name'] : $auth['name']), array('viewitem', 'userid' => $user['userid'], 'itemid' => $auth['auth_id'])); if ($auth['description']) { echo "<br/>{$auth['description']}"; } if (isset($auth['cond']) && $auth['cond']) { echo "<br/><br/>Condition: {$auth['cond']}"; } if (isset($auth['bizrule']) && $auth['bizrule']) { echo "<br/><br/>PHP Rule: "; $syntaxHighlighter = new CTextHighlighter(); $syntaxHighlighter->language = 'PHP'; $syntaxHighlighter->processOutput($auth['bizrule']); if (isset($auth['data']) && $auth['data']) { echo "<br/><br/>PHP Data: "; $syntaxHighlighter->processOutput($auth['data']); } } echo "</td>"; } } ?> </tbody> </table> <br/> <?php
/** * Подсветка php-кода * @param string $code * @return string */ protected function highlightPhp($code) { if ($this->_hl === null) { $this->_hl = Yii::createComponent(array('class' => 'CTextHighlighter', 'language' => 'php', 'showLineNumbers' => false)); } $html = $this->_hl->highlight($code); return strip_tags($html, '<div>,<span>'); }
/** * Подсветка sql-кода * @param string $sql * @return string */ public function highlightSql($sql) { if ($this->_hl === null) { $this->_hl = Yii::createComponent(array('class' => 'CTextHighlighter', 'language' => 'sql', 'showLineNumbers' => false)); } $html = $this->_hl->highlight($sql); return strip_tags($html, '<div>,<span>'); }
<?php $this->breadcrumbs = array('Access Control' => array('hrbacuser/list'), 'View:' . $model->name); $this->menu = array(array('label' => 'Edit This Item', 'url' => array('update', 'id' => $model->auth_id)), array('label' => 'Include Other Items', 'url' => array('include', 'id' => $model->auth_id), 'visible' => $model->type > 0), array('label' => 'Delete This Item', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->auth_id), 'confirm' => 'Are you sure to delete this item?')), array('label' => 'Users Having This', 'url' => array('hrbacuser/list', 'authid' => $model->auth_id)), array('label' => ' '), array('label' => ' '), array('label' => 'List Auth Items', 'url' => array('index')), array('label' => 'Create Auth Item', 'url' => array('create')), array('label' => 'Manage Auth Items', 'url' => array('admin')), array('label' => 'User Permissions', 'url' => array('hrbacuser/list'))); ?> <h1>View: <?php echo $model->alt_name ? $model->alt_name : $model->name; ?> </h1> <?php $type = array('Operation', 'Op Group', 'Role'); $syntaxHighlighter = new CTextHighlighter(); $syntaxHighlighter->language = 'PHP'; $attributes = array('name', 'alt_name', array('label' => 'Type', 'value' => $type[$model->type]), 'description', 'cond', array('name' => 'bizrule', 'type' => 'raw', 'value' => $syntaxHighlighter->highlight($model->bizrule))); function listAuthAttr($items, $label, $type) { $attr = array(); foreach ($items as $item) { $name = $item['alt_name'] ? $item['alt_name'] : $item['name']; $attr[] = '(' . $type[$item->type] . ') ' . CHtml::link(CHtml::encode($name), array('view', 'id' => $item['auth_id'])); } if (count($attr)) { return array('label' => $label, 'type' => 'raw', 'value' => implode(', ', $attr)); } else { return array(); } } if (($attr = listAuthAttr($model->authChildren, 'Directly Includes', $type)) !== array()) { $attributes[] = $attr;
<?php $this->pageTitle = Yii::t('auth', 'Auth Item Assignment'); $this->breadcrumbs = array(Yii::t("auth", "Access Control") => array('hrbacitem/index'), Yii::t("auth", "Auth Item Assignment")); $this->menu = array(array('label' => Yii::t('auth', 'Edit This Assignment'), 'url' => array('edititem', 'userid' => $data['user_id'], 'itemid' => $data['auth_id'])), array('label' => Yii::t('auth', 'Remove This Assignment'), 'url' => '#', 'linkOptions' => array('submit' => array('removeitem', 'userid' => $data['user_id'], 'itemid' => $data['auth_id']), 'confirm' => 'Are you sure to remove this assignment?')), array('label' => ' '), array('label' => ' '), array('label' => Yii::t('auth', 'Create Auth Item'), 'url' => array('create')), array('label' => Yii::t('auth', 'Assign Auth Item'), 'url' => array('assign')), array('label' => 'List Auth Items', 'url' => array('hrbacitem/index')), array('label' => 'User Permissions', 'url' => array('hrbacuser/list'))); $name = $data['alt_name'] ? $data['alt_name'] : $data['authname']; echo "<h2>Assignment of '{$name}' to '{$data['username']}'</h2>"; $type = array('Operation', 'Op Group', 'Role'); $syntaxHighlighter = new CTextHighlighter(); $syntaxHighlighter->language = 'PHP'; $attributes = array(array('label' => 'User', 'value' => $data['username']), array('label' => 'Auth', 'type' => 'raw', 'value' => CHtml::link(CHtml::encode($name), array('hrbacitem/view', 'id' => $data['auth_id']))), array('label' => 'Type', 'value' => $type[$data['type']]), array('name' => 'description', 'label' => 'Description'), array('name' => 'cond', 'label' => 'Condition'), array('name' => 'bizrule', 'label' => 'PHP Rule', 'type' => 'raw', 'value' => $syntaxHighlighter->highlight($data['bizrule']))); // $model = $data['model']; function listAuthAttr($items, $label, $type) { $attr = array(); foreach ($items as $item) { $name = $item['alt_name'] ? $item['alt_name'] : $item['name']; $attr[] = '(' . $type[$item->type] . ') ' . CHtml::link(CHtml::encode($name), array('viewitem', 'id' => $item['auth_id'])); } if (count($attr)) { return array('label' => $label, 'type' => 'raw', 'value' => implode(', ', $attr)); } else { return array(); } } if (($attr = listAuthAttr($model->authChildren, 'Directly Includes', $type)) !== array()) { $attributes[] = $attr; } if (($attr = listAuthAttr($model->getAuthDescendants(2), 'Indirectly Includes', $type)) !== array()) { $attributes[] = $attr;
/** * Получить код inline-виджета * **/ public function getInlineWidgetCode($highlight = true) { // Шаблон $code = "[[w:ContentBlock|code={$this->code}]]"; // Подсветка if ($highlight) { $highlighter = new CTextHighlighter(); $highlighter->language = 'PHP'; $code = $highlighter->highlight($code); } return $code; }
?> <br /> <?php } ?> <?php if (!empty($data->bizrule)) { ?> <b><?php echo CHtml::encode($data->getAttributeLabel('bizrule')); ?> :</b> <?php //echo CHtml::encode($data->bizrule); $syntaxHighlighter = new CTextHighlighter(); $syntaxHighlighter->language = 'PHP'; $syntaxHighlighter->processOutput($data->bizrule); ?> <br /> <?php } ?> <?php $authChildren = $data->authChildren; if (count($authChildren)) { echo '<b>Includes: </b>'; foreach ($authChildren as $authItem) { $name = $authItem->alt_name ? $authItem->alt_name : $authItem->name; echo '(' . $type[$authItem->type] . ') ' . CHtml::link(CHtml::encode($name), array('view', 'id' => $authItem->auth_id)) . '. ';
textHtml = textHtml + "<p>Url запроса:"+data.requestUrl+"</p>"; textHtml = textHtml + "<p>Время отправки запроса:"+data.timestamp+"</p>"; textHtml = textHtml + "<p>XML запроса:</p>"; textHtml = textHtml + data.requestXml; textHtml = textHtml + "<p>Время ожидания ответа:"+data.executionTime+" сек</p>"; if(!jQuery.isEmptyObject(data.errorDescription)){ textHtml = textHtml + "<p>Описание ошибки:"+data.errorDescription+"</p>"; } if(!jQuery.isEmptyObject(data.responseXml)){ textHtml = textHtml + "<p>XML ответа:</p>"; textHtml = textHtml + data.responseXml; } $(\'#popupInfo .modal-body\').html(textHtml); //btn.button("reset"); //var two = data.priceTo + data.priceBack; //btn.append(" <b>Цена: </b>"+Math.min(data.priceTo + data.priceBack, data.priceToBack) + " руб. (2 билета = " + two + " руб., туда-обратно = " + data.priceToBack + " руб.)"); }) .fail(function(data){ $(\'#popupInfo .modal-body\').html("Ошибка сервера"); //btn.button("reset"); //btn.html("Произошёл сбой"); //e.preventDefault(); }); }; if(window.location.hash){ var id = window.location.hash; document.showRequestInfo(id); } ', CClientScript::POS_READY); CTextHighlighter::registerCssFile();