/**
  * 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?>";
     $codeCategory = "<?php \$this->widget(\n\t\"application.modules.contentblock.widgets.ContentBlockGroupWidget\",\n\tarray(\"category\" => \"{$model->getCategoryAlias()}\"));\n?>";
     $highlighter = new CTextHighlighter();
     $highlighter->language = 'PHP';
     $example = $highlighter->highlight($code);
     $exampleCategory = $highlighter->highlight($codeCategory);
     $this->render('view', ['model' => $model, 'example' => $example, 'exampleCategory' => $exampleCategory]);
 }
Exemple #2
0
 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('!&lt;code&gt;(.*?)&lt;/code&gt;!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})*)*(\?(&amp;?([-+_~.\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;
 }
 protected function afterValidate()
 {
     $highlighter = new CTextHighlighter();
     $highlighter->language = $this->language;
     $this->html = $highlighter->highlight($this->code);
     return parent::afterValidate();
 }
 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;
 }
 /**
  * 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(\"application.modules.contentblock.widgets.ContentBlockWidget\", array(\"code\" => \"{$model->code}\")); ?>";
     $highlighter = new CTextHighlighter();
     $highlighter->language = 'PHP';
     $example = $highlighter->highlight($code);
     $this->render('view', array('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 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;
 }
Exemple #9
0
 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 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();
     }
 }
 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;
 }
Exemple #12
0
$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 
$list = array();
foreach ($data['allAuths'] as $auth) {
    $name = $auth['alt_name'] ? $auth['alt_name'] : $auth['name'];
    $list[] = '(' . $type[$auth['type']] . ') ' . CHtml::link(CHtml::encode($name), array('viewitem', 'userid' => $data['userid'], 'itemid' => $auth['auth_id']));
}
echo implode(", ", $list);
 /**
  * Получить код 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;
 }
Exemple #14
0
 /**
  * Подсветка 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>');
 }
Exemple #15
0
 /**
  * Подсветка 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>');
 }
Exemple #16
0
<?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;
Exemple #17
0
<?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;