Say I want to use use a widget in a view thus:
<?php
$this->widget('MyWidget');And the definition is quite conventional:
| #!/usr/bin/php | |
| <?php | |
| /** | |
| * @var | |
| */ | |
| // check arguments | |
| if ($argc !== 3 || !is_readable($argv[1]) || !is_readable($argv[2]) ) { | |
| fwrite(STDERR, <<<EOT | |
| Usage: {$argv[0]} csd_export_file ide_color_file |
| <?php | |
| // this is how to use the dateRange helpers in your view | |
| $this->widget('zii.widgets.grid.CGridView', array( | |
| 'afterAjaxUpdate' => Help::dateRangeInitJs(), | |
| 'dataProvider' => $model->search(), | |
| 'filter' => $model, | |
| 'columns' => array( | |
| Help::dateRangeCol($model, 'dateAttr', array('header' => 'The date')), | |
| ), |
| <?php | |
| function clean_utf8($s) { | |
| return iconv('UTF-8', 'UTF-8//IGNORE', $s); | |
| } | |
| function check_utf8($s) { | |
| return mb_check_encoding($s, 'UTF-8'); | |
| } |
Say I want to use use a widget in a view thus:
<?php
$this->widget('MyWidget');And the definition is quite conventional:
| <?php | |
| private static function _checkClassPath($path) | |
| { | |
| if (basename(realpath($path . '.php')) !== $path . '.php') | |
| throw new CException("Class name does not match file name."); | |
| } | |
| /** | |
| * Class autoload loader. | |
| * This method is provided to be invoked within an __autoload() magic method. |
| <?php | |
| /** | |
| * Generate an external URL with scheme, hostname and etc. under any(?) circumstances | |
| * | |
| * @param mixed $url Specs for the url, as CHtml::normalizeUrl() would expect | |
| * @param string $scheme 'http' or 'https' | |
| * @throws CException on missing 'extBaseUrl' app param in non-webapp context | |
| * @return string | |
| */ | |
| public static function hardUrl($url, $scheme = 'http') { |
| <?php | |
| /** | |
| * This package contains a widget class and two action method classes that the | |
| * widget provides to the CController that uses it. | |
| * | |
| * The controller must register the actions provided by this widget as follows, | |
| * in which we assume this package is in the 'extensions' directory under | |
| * CWebApplication::$basePath | |
| * <code> |
| <?php | |
| preg_match( | |
| '%' | |
| . preg_quote($marker, '%') | |
| . '\{ | |
| (?:[^{}]*\{ | |
| (?:[^{}]*\{ | |
| (?:[^{}]*\{ | |
| (?:[^{}]*\{ |
| <?php | |
| // On my mac, cmd-opt-L reformats my php files according to the code style in effect. | |
| // The following is how PhpStorm auto-formats this statement. | |
| // What do I have to set in the code style so it comes out right? | |
| if (isset( | |
| $_SESSION['one'], | |
| $_SESSION['two'], | |
| $_SESSION['three'], |
| #!/usr/local/bin/php | |
| <?php | |
| $error = false; | |
| $errno = 0; | |
| try { | |
| $db = new PDO('mysql:dbname=stations;host=localhost', 'root', 'password'); | |
| $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| /** @var $slave_status StdClass */ |