isUTF8

26. Januar 2012
function isUTF8($str)
{
  return preg_match('/^([\x09\x0A\x0D\x20-\x7E]|[\xC2][\xA0-\xBF]|[\xC3-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/', $str);
}
Author: Categories: PHP Tags:

CDetailView in Sidebar anzeigen

24. Januar 2012

Problem:

die th-Spalte im DetailView ist per CSS 160px breit, passt nicht so einfach in eine schmale Sidebar

Lösung:

class UserInfo extends CWidget
{
  public $user;
 
  public function run()
  {
    Yii::app()->clientScript->registerCss('sidebar', 'table.sidebar th {width: 100px;}');
    $this->widget('zii.widgets.CDetailView', array(
      'data' => $this->user,
      'htmlOptions' => array('class' => 'detail-view sidebar'),
      'attributes' => array(
        'firstname',
        'lastname'
      ),
    ));
  }
}
Author: Categories: Yii Tags:

jQueryUI-Theme ändern

23. Januar 2012

Theme hier runterladen.
Den Ordner redmond nach framework/web/js/source/jui/css kopieren.
Datei jquery-ui-1.8.17.custom.css umbenennen in jquery-ui.css.
Assets-Ordner leeren.

//framework/zii/widgets/jui/CJuiWidget.php
public $theme='redmond';
//view.php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'mydialog',
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Dialog box 1',
        'autoOpen'=>false,
    ),
));
 
    echo 'dialog content here';
 
$this->endWidget('zii.widgets.jui.CJuiDialog');
 
// the link that may open the dialog
echo CHtml::link('open dialog', '#', array(
   'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
Author: Categories: Yii Tags:

Highcharts

19. Januar 2012

Diagramme erstellen kann man mit der Highcharts-Extension:

 

Author: Categories: Yii Tags:

renderPortlets

16. Januar 2012
//views/layouts.main.php
<div class="span-6 last">
  <div id="sidebar">
    <?php $this->renderPortlets('right'); ?>
  </div>
</div>
//components/Controller.php
class Controller extends CController
{   
  public $portlets = array();
 
  public function addPortlet($position, $portlet)
  {
    $this->portlets[$position][] = $portlet;
  }
 
  public function renderPortlets($position)
  {
    if (isset($this->portlets[$position])) {
      foreach ($this->portlets[$position] as $portlet) {
        $this->beginWidget('zii.widgets.CPortlet', array(
          'title' => $portlet['title'],
        ));
        $this->widget($portlet['class'], $portlet['params']);
        $this->endWidget();
      }
    }
  }
}
//views/article/view.php
$this->addPortlet('right', array(
  'class' => 'zii.widgets.CMenu',
  'title' => 'Operations',
  'params' => array( //Configuration CMenu
    'items' => array(
      array('label' => 'List Article', 'url' => array('index')),
      array('label' => 'Create Article', 'url' => array('create')),
      array('label' => 'Update Article', 'url' => array('update', 'id' => $model->id)),
      array('label' => 'Delete Article', 'url' => '#', 'linkOptions' => array('submit' =>
        array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')),
      ),
    'htmlOptions' => array('class' => 'operations')
  )
));
 
$this->addPortlet('right', array(
  'class' => 'ArticleInfoWidget',
  'title' => 'ArticleInfo',
  'params' => array(
    'article' => $model
  )
));
Author: Categories: Yii Tags: ,

3-spaltiges Layout

7. Januar 2012
//css/main.css
#sidebar-left
{
    padding: 20px 0 20px 20px;
}
//protected/views/layouts/column3.php
<?php $this->beginContent('//layouts/main'); ?>
<div class="container">
 
    <div class="span-6">
        <div id="sidebar-left">
	    <?php $this->renderPortlets('left'); ?>
	</div>
    </div>
 
    <div class="span-12">
        <div id="content">
            <?php echo $content; ?>
	</div>
    </div>
 
    <div class="span-6 last">
        <div id="sidebar">
	    <?php $this->renderPortlets('right'); ?>
	</div>
    </div>
 
</div>
<?php $this->endContent(); ?>
//Controller.php
public $layout = '//layouts/column3';
Author: Categories: Yii Tags:

phploc yiiframework 1.1.9

1. Januar 2012
C:\Users\mbi\Downloads\yii-1.1.9.r3527>phploc framework
phploc 1.6.1 by Sebastian Bergmann.
 
Directories:                                        163
Files:                                             1471
 
Lines of Code (LOC):                             596876
  Cyclomatic Complexity / Lines of Code:           0.02
Comment Lines of Code (CLOC):                     50628
Non-Comment Lines of Code (NCLOC):               546248
 
Namespaces:                                           0
Interfaces:                                          28
Classes:                                            629
  Abstract:                                          54 (8.59%)
  Concrete:                                         575 (91.41%)
  Average Class Length (NCLOC):                     122
Methods:                                           4407
  Scope:
    Non-Static:                                    4074 (92.44%)
    Static:                                         333 (7.56%)
  Visibility:
    Public:                                        3397 (77.08%)
    Non-Public:                                    1010 (22.92%)
  Average Method Length (NCLOC):                     17
  Cyclomatic Complexity / Number of Methods:       3.41
 
Anonymous Functions:                                  0
Functions:                                            0
 
Constants:                                          200
  Global constants:                                  46
  Class constants:                                  154
Author: Categories: Yii Tags: