/**
  * {@inheritdoc}
  */
 public function getTitle()
 {
     if (false !== $this->_cache) {
         return YiiDebug::t('Cache requests');
     }
     return YiiDebug::t('No cache usage');
 }
Example #2
0
function RemoveDir($path)
{
    if (file_exists($path) && is_dir($path)) {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle))) {
            if ($file != '.' && $file != '..') {
                $tmpPath = $path . '/' . $file;
                chmod($tmpPath, 0777);
                if (is_dir($tmpPath)) {
                    RemoveDir($tmpPath);
                } else {
                    if (file_exists($tmpPath)) {
                        unlink($tmpPath);
                    }
                }
            }
        }
        closedir($dirHandle);
        if (file_exists($path)) {
            rmdir($path);
        }
    } else {
        throw new Exception(YiiDebug::t('Failed to delete folder.'));
    }
}
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $resources = array(YiiDebug::t('Page Load Time') => sprintf('%0.3F s.', $this->getLoadTime()), YiiDebug::t('Elapsed Time') => sprintf('%0.3F s.', $this->getRequestLoadTime()), YiiDebug::t('Memory Usage') => number_format(Yii::getLogger()->getMemoryUsage() / 1024) . ' KB', YiiDebug::t('Memory Peak Usage') => number_format(memory_get_peak_usage() / 1024) . ' KB');
     if (function_exists('mb_strlen') && isset($_SESSION)) {
         $resources[YiiDebug::t('Session Size')] = sprintf('%0.3F KB', mb_strlen(serialize($_SESSION)) / 1024);
     }
     $this->render('resource_usage', array('resources' => $resources));
 }
 public function actionCreate()
 {
     $model = $this->loadModel();
     if (null !== ($formData = Yii::app()->request->getPost(get_class($model)))) {
         $model->setAttributes($formData);
         if (Yii::app()->request->isAjaxRequest) {
             echo CActiveForm::validate($model);
             Yii::app()->end();
         }
         YiiDebug::dump($model->validate());
         YiiDebug::dump($model->errors);
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $resources = array(YiiDebug::t('Page Load Time') => sprintf('%0.6F s.', $this->getLoadTime()), YiiDebug::t('Elapsed Time') => sprintf('%0.6F s.', $this->getRequestLoadTime()), YiiDebug::t('Memory Usage') => number_format(Yii::getLogger()->getMemoryUsage() / 1024) . ' KB', YiiDebug::t('Memory Peak Usage') => function_exists('memory_get_peak_usage') ? number_format(memory_get_peak_usage() / 1024) . ' KB' : 'N/A');
     if (function_exists('mb_strlen') && isset($_SESSION)) {
         $resources[YiiDebug::t('Session Size')] = sprintf('%0.3F KB', mb_strlen(serialize($_SESSION)) / 1024);
     }
     echo CHtml::openTag('div', $this->htmlOptions);
     echo CHtml::tag('h1', array(), $this->title);
     echo CHtml::openTag('ul', array('class' => 'data'));
     foreach ($resources as $key => $value) {
         echo CHtml::openTag('li');
         echo CHtml::tag('label', array(), $key);
         echo CHtml::tag('span', array(), $value);
         echo CHtml::closeTag('li');
     }
     echo CHtml::closeTag('ul');
     echo CHtml::closeTag('div');
 }
Example #6
0
        <tr>
            <th class="collapsible collapsed al-l" rel="#yii-debug-toolbar-log .details">
                <?php 
echo YiiDebug::t('Message (details)');
?>
</th>
            <th nowrap="nowrap"><?php 
echo YiiDebug::t('Level');
?>
</th>
            <th nowrap="nowrap" class="al-l"><?php 
echo YiiDebug::t('Category');
?>
</th>
            <th nowrap="nowrap"><?php 
echo YiiDebug::t('Time');
?>
</th>
        </tr>
    </thead>
    <tbody>
    <?php 
foreach ($logs as $id => $entry) {
    ?>
        <tr class="<?php 
    echo $id % 2 ? 'odd' : 'even';
    ?>
"
            <?php 
    if (isset($colors[$entry[1]])) {
        ?>
Example #7
0
    </tbody>
</table>

<h4 class="collapsible"><?php 
echo YiiDebug::t('Components');
?>
</h4>
<table>
    <thead>
        <tr>
            <th width="180"><?php 
echo YiiDebug::t('Component ID');
?>
</th>
            <th><?php 
echo YiiDebug::t('Configuration');
?>
</th>
        </tr>
    </thead>
    <tbody>
        <?php 
$c = 0;
foreach ($components as $key => $value) {
    ?>
        <tr class="<?php 
    echo $c % 2 ? 'odd' : 'even';
    ?>
">
            <th><?php 
    echo $key;
 /**
  * {@inheritdoc}
  */
 public function getTitle()
 {
     return YiiDebug::t('Request');
 }
 /**
  * {@inheritdoc}
  */
 public function getTitle()
 {
     return YiiDebug::t('Views Rendering');
 }
 /**
  * Initialization.
  */
 public function init()
 {
     if (false === $this->owner instanceof CLogRoute) {
         throw new CException(YiiDebug::t('YiiDebugToolbar owner must be instance of CLogRoute'));
     }
     $this->createPanels()->registerClientScripts();
 }
Example #11
0
 /**
  * Create panels.
  *
  * @return YiiDebugToolbar
  */
 private function createPanels()
 {
     foreach ($this->getPanels() as $id => $config) {
         if (!is_object($config)) {
             if (is_string($config)) {
                 $config = array('class' => $config);
             }
             if (is_array($config)) {
                 if (is_array($config) && !isset($config['class'])) {
                     $config['class'] = $id;
                 }
                 if (isset($config['enabled']) && false === $config['enabled']) {
                     unset($this->_panels[$id]);
                     continue;
                 } else {
                     if (isset($config['enabled']) && true === $config['enabled']) {
                         unset($config['enabled']);
                     }
                 }
             }
             $panel = Yii::createComponent($config, $this);
             if (false === $panel instanceof YiiDebugToolbarPanelInterface) {
                 throw new CException(YiiDebug::t('The %class% class must be compatible with YiiDebugToolbarPanelInterface', array('%class%' => get_class($panel))));
             }
             $panel->init();
             $this->_panels[$id] = $panel;
         }
     }
     return $this;
 }
                <?php 
$this->widget('YiiDebugToolbarResourceUsage', array('title' => 'Resource usage', 'htmlOptions' => array('class' => 'panel')));
?>
        </div>
    </div>

    <?php 
foreach ($panels as $panel) {
    ?>
    <div id="<?php 
    echo $panel->id;
    ?>
" class="yii-debug-toolbar-panel">
        <div class="yii-debug-toolbar-panel-title">
        <a href="#close" class="yii-debug-toolbar-panel-close"><?php 
    echo YiiDebug::t('Close');
    ?>
</a>
        <h3>
            <?php 
    echo CHtml::encode($panel->title);
    ?>
            <?php 
    if ($panel->subTitle) {
        ?>
            <small><?php 
        echo CHtml::encode($panel->subTitle);
        ?>
</small>
            <?php 
    }
 /**
  * Returns the DB server info by connection ID.
  * @param string $connectionId
  * @return mixed
  */
 public function getServerInfo($connectionId)
 {
     if (null !== ($connection = Yii::app()->getComponent($connectionId)) && false !== $connection instanceof CDbConnection && !in_array($connection->driverName, array('sqlite', 'oci', 'dblib')) && '' !== ($serverInfo = $connection->getServerInfo())) {
         $info = array(YiiDebug::t('Driver') => $connection->getDriverName(), YiiDebug::t('Server Version') => $connection->getServerVersion());
         $lines = explode('  ', $serverInfo);
         foreach ($lines as $line) {
             list($key, $value) = explode(': ', $line, 2);
             $info[YiiDebug::t($key)] = $value;
         }
         if (!empty($info[YiiDebug::t('Uptime')])) {
             $info[YiiDebug::t('Uptime')] = $this->duration($info[YiiDebug::t('Uptime')]);
         }
         return $info;
     }
     return null;
 }
 /**
  * Displays a variable.
  * This method achieves the similar functionality as var_dump and print_r
  * but is more robust when handling complex objects such as Yii controllers.
  * @param mixed $var variable to be dumped
  */
 public function dump($var)
 {
     YiiDebug::dump($var);
 }
Example #15
0
</label>
                        &nbsp;=>&nbsp;
                        <span><label><?php 
                YiiDebug::dump($value, 0);
                ?>
</label></span>
                    </li>
                    <?php 
            }
            ?>
                </ul>
                <?php 
        } else {
            ?>
                    <?php 
            YiiDebug::dump(null);
            ?>
                <?php 
        }
        ?>
            </td>
        </tr>
        <?php 
    }
    ?>

    </tbody>
</table>
</div>
<?php 
}
Example #16
0
<div data-ydtb-tabs="<?php 
echo $this->id;
?>
">
    <ul>
        <li><a href="#cache-summary"><i data-ydtb-icon="s"></i><?php 
echo YiiDebug::t('Summary');
?>
</a></li>
        <li><a href="#cache-callstack"><i data-ydtb-icon="s"></i><?php 
echo YiiDebug::t('Callstack');
?>
</a></li>
        <li><a href="#cache-settings"><i data-ydtb-icon="s"></i><?php 
echo YiiDebug::t('Settings');
?>
</a></li>
    </ul>
    <div data-ydtb-panel-data="<?php 
echo $this->id;
?>
">
            <div>
                <div data-ydtb-tab="cache-settings">
                    <?php 
$this->render('cache/settings', array('settings' => $settings));
?>
                </div>
                <div data-ydtb-tab="cache-summary">
                    <?php 
$this->render('cache/summary', array('summary' => $summary));
 /**
  * Processing summary.
  *
  * @param array $logs Logs.
  * @return array
  */
 protected function processSummary(array $logs)
 {
     if (empty($logs)) {
         return $logs;
     }
     $stack = array();
     foreach ($logs as $log) {
         $message = $log[0];
         if (0 === strncasecmp($message, 'begin:', 6)) {
             $log[0] = substr($message, 6);
             $stack[] = $log;
         } else {
             if (0 === strncasecmp($message, 'end:', 4)) {
                 $token = substr($message, 4);
                 if (null !== ($last = array_pop($stack)) && $last[0] === $token) {
                     $delta = $log[3] - $last[3];
                     if (isset($results[$token])) {
                         $results[$token] = $this->aggregateResult($results[$token], $delta);
                     } else {
                         $results[$token] = array($token, 1, $delta, $delta, $delta);
                     }
                 } else {
                     throw new CException(YiiDebug::t('Mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.', array('{token}' => $token)));
                 }
             }
         }
     }
     $now = microtime(true);
     while (null !== ($last = array_pop($stack))) {
         $delta = $now - $last[3];
         $token = $last[0];
         if (isset($results[$token])) {
             $results[$token] = $this->aggregateResult($results[$token], $delta);
         } else {
             $results[$token] = array($token, 1, $delta, $delta, $delta);
         }
     }
     $entries = array_values($results);
     $func = create_function('$a,$b', 'return $a[4]<$b[4]?1:0;');
     usort($entries, $func);
     return array_map(array($this, 'formatLogEntry'), $entries);
 }
 /**
  * {@inheritdoc}
  */
 public function getTitle()
 {
     return YiiDebug::t('Log Messages');
 }
 /**
  * {@inheritdoc}
  */
 public function getTitle()
 {
     return YiiDebug::t('Global Variables');
 }
Example #20
0
<?php

if ($settings) {
    ?>
	<table data-ydtb-data-table="fixed">
		<tbody>
		<?php 
    foreach ($settings as $key => $value) {
        ?>
			<tr>
				<th><?php 
        echo $key;
        ?>
</th>
				<td><?php 
        echo $this->dump($value);
        ?>
</td>
			</tr>
		<?php 
    }
    ?>
		</tbody>
	</table>
<?php 
} else {
    ?>
	<?php 
    echo YiiDebug::t('Cache not configured');
}
Example #21
0
<?php

if ($connections) {
    foreach ($connections as $id => $connection) {
        ?>
<h2><?php 
        echo YiiDebug::t('Connection ID');
        ?>
: <?php 
        echo $id;
        ?>
 (<?php 
        echo get_class($connection);
        ?>
)</h2>
<?php 
        $serverInfo = $this->getServerInfo($id);
        ?>
    <table data-ydtb-data-table>
        <tbody>
        <?php 
        if (is_array($serverInfo)) {
            ?>
            <?php 
            foreach ($serverInfo as $param => $value) {
                ?>
            <tr>
                <th><?php 
                echo CHtml::encode($param);
                ?>
</th>
Example #22
0
<div id="ydtb-toolbar" data-ydtb-toolbar class="ydtb-collapse">
    <a href="javascript://" data-ydtb-toggle="[data-ydtb-toolbar]"><?php 
echo YiiDebug::t('TOOLBAR');
?>
</a>
	<div data-ydtb-sidebar>
		<h1>Yii <?php 
echo Yii::getVersion();
?>
</h1>
		<?php 
$this->widget('YiiDebugToolbarResourceUsage');
?>
		<ul data-ydtb-menu>
			<?php 
foreach ($panels as $panel) {
    ?>
			<li><a href="javascript://" data-ydtb-expand-panel="<?php 
    echo $panel->id;
    ?>
">
			    <i data-ydtb-icon="<?php 
    echo $panel->i;
    ?>
"></i>
			    <?php 
    if (null !== $panel->menuSubTitle) {
        ?>
 <small><?php 
        echo $panel->menuSubTitle;
        ?>
Example #23
0
}
?>
    
    <h4 class="collapsible">SERVER <?php 
echo YiiDebug::t('Variables');
?>
</h4>
    <table id="debug-toolbar-globals-server">
        <thead>
            <tr>
                <th><?php 
echo YiiDebug::t('Name');
?>
</th>
                <th><?php 
echo YiiDebug::t('Value');
?>
</th>
            </tr>
        </thead>
        <tbody>
            <?php 
$c = 0;
foreach ($server as $key => $value) {
    ?>
            <tr class="<?php 
    echo $c % 2 ? 'odd' : 'even';
    ?>
">
                <th><?php 
    echo $key;
 /**
  * {@inheritdoc}
  */
 public function getTitle()
 {
     return YiiDebug::t('Server Info');
 }
            <?php 
    foreach ($files as $key => $value) {
        ?>
            <tr class="<?php 
        echo $c % 2 ? 'odd' : 'even';
        ?>
">
                <th><?php 
        echo $key;
        ?>
</th>
                <td><?php 
        echo $this->dump($value);
        ?>
</td>
            </tr>
            <?php 
        ++$c;
    }
    ?>
        </tbody>
    </table>
    <?php 
} else {
    ?>
    <h4>FILES</h4>
    <?php 
    echo YiiDebug::t('No FILES data');
    ?>
    <?php 
}
Example #26
0
<?php

/**
 * @var $this YiiDebugToolbarPanelVarDumper
 */
foreach ($this->getLogs() as $category => $categoryLogs) {
    $c = 0;
    echo CHtml::tag('h4', array('class' => 'collapsible'), $category);
    echo CHtml::openTag('table');
    echo CHtml::openTag('thead');
    echo CHtml::openTag('tr');
    echo CHtml::tag('th', array(), YiiDebug::t('Value'));
    echo CHtml::tag('th', array('width' => '10%'), YiiDebug::t('Time'));
    echo CHtml::closeTag('tr');
    echo CHtml::closeTag('thead');
    echo CHtml::openTag('tbody');
    foreach ($categoryLogs as $log) {
        echo CHtml::openTag('tr', array('class' => $c % 2 ? 'odd' : 'even'));
        echo CHtml::tag('td', array(), $log[0]);
        echo CHtml::tag('td', array(), date('H:i:s.', $log[3]) . sprintf('%06d', (int) (($log[3] - (int) $log[3]) * 1000000)));
        echo CHtml::closeTag('tr');
        $c++;
    }
    echo CHtml::closeTag('tbody');
    echo CHtml::closeTag('table');
}
Example #27
0
    echo $summary['delete'];
    ?>
</td>
			<td><?php 
    printf('%0.6F', $summary['delete_time']);
    ?>
 s</td>
		</tr>
		<tr>
			<th>flush</th>
			<td><?php 
    echo $summary['flush'];
    ?>
</td>
			<td><?php 
    printf('%0.6F', $summary['flush_time']);
    ?>
 s</td>
		</tr>
	</tbody>
</table>
<?php 
} else {
    ?>
	<p>
		<?php 
    echo YiiDebug::t('No cache request logged or profiling the cache is DISABLED.');
    ?>
	</p>
<?php 
}
 public function getTitle()
 {
     return YiiDebug::t('Application Settings');
 }
 public function getTitle()
 {
     return YiiDebug::t('VarDumper output');
 }
Example #30
0
        <?php 
}
?>

    </tbody>
</table>

<script type="text/javascript">
	function deleteAsset(link, blockAll){
		$.getJSON(link.href, {}, function(data){
			if(data == 'ok'){
				$(link).parents('tr').remove();
				if(blockAll){
					$('a.deleteAsset').remove();
				}
			}
			if(data == 'notexists'){
				alert('<?php 
echo YiiDebug::t('Path not found.');
?>
');
			}
			if(data == 'unknow'){
				alert('<?php 
echo YiiDebug::t('Unknow error.');
?>
');
			}
		});
	}
</script>