Пример #1
0
 /**
  * Функция отрисовки виджета:
  *
  * @param string $className     - имя класса
  * @param mixed  $properties    - параметры
  * @param bool   $captureOutput - требуется ли "захват" вывода виджета
  *
  * @return mixed Инстанс виджета в случае, когда $captureOutput является ложным,
  * или вывод виджета, когда $captureOutput - истина
  **/
 public function widget($className, $properties = array(), $captureOutput = false)
 {
     try {
         $modulePath = explode('.', $className);
         $isModule = strpos($className, 'application.modules') !== false && !empty($modulePath[2]) && !Yii::app()->hasModule($modulePath[2]);
         if (Yii::getPathOfAlias($className) == false || $isModule) {
             $modulePath = explode('.', $className);
             if ($isModule) {
                 throw new CException(Yii::t('YupeModule.yupe', 'Widget "{widget}" was not found! Please enable "{module}" module!', array('{widget}' => $className, '{module}' => $modulePath[2])), 1);
             } elseif (class_exists($className) === false) {
                 throw new CException(Yii::t('YupeModule.yupe', 'Widget "{widget}" was not found!', array('{widget}' => $className)), 1);
             }
         }
         $widget = parent::widget($className, $properties, $captureOutput);
     } catch (CException $e) {
         echo CHtml::tag('p', array('class' => 'alert alert-error'), $e->getCode() ? $e->getMessage() : Yii::t('YupeModule.yupe', 'Error occurred during the render widget ({widget}): {error}', array('{error}' => $e->getMessage(), '{widget}' => $className)));
         return null;
     }
     return $widget;
 }
Пример #2
0
    /**
     * add profile information to std widget call
     *
     * @param string $className
     * @param array $properties
     * @param bool $captureOutput
     * @return mixed
     */
    public function widget($className,$properties=array(),$captureOutput=false)
    {
        $profile_id = 'Widget::'.$className;

        //profile widget
        Yii::beginProfile($profile_id);
        $res = parent::widget($className,$properties,true);
        Yii::endProfile($profile_id);

        if ($captureOutput)
        {
            return $res;
        }
        else
        {
            echo $res;
        }
    }
Пример #3
0
    /**
     * add profile information to std widget call
     *
     * @param string $className
     * @param array  $properties
     * @param bool   $captureOutput
     *
     * @return mixed
     */
    public function widget($className, $properties = array(), $captureOutput = false)
    {
        $profile_id = 'Widget::' . $className;

        //profile widget
//        Yii::beginProfile($profile_id);
        $res = parent::widget($className, $properties, $captureOutput);
//        Yii::endProfile($profile_id);
        return $res;
    }
Пример #4
0
 /**
  * Dump variable of rows, into web or HTML I/O. rows must be from resulted
  * on sql query.
  * @param CController $controller
  * @param string[][] $rows
  */
 public static function dumpRows($controller, $rows)
 {
     if (count($rows) > 0) {
         $controller->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CArrayDataProvider($rows, array('keyField' => 'Code', 'pagination' => false)), 'columns' => array_keys($rows[0])));
     }
 }
Пример #5
0
/**
 * Created by PhpStorm.
 * User: james
 * Date: 7/14/15
 * Time: 9:58 AM
 * @var $editAccess bool
 * @var $editMode bool
 * @var $content DocPages
 * @var $this ContextController
 */
if ($editAccess) {
    $submitUrl = $this->createUrl($this->action->id);
    if (isset($_GET['id'])) {
        $submitUrl = $this->createUrl($this->action->id, ['id' => $_GET['id']]);
    }
    if (!$editMode) {
        echo CHtml::htmlButton(Yii::t('translation', 'Edit'), array('submit' => $submitUrl, 'params' => ['page' => $content->docId], 'type' => 'submit', 'style' => 'float:right;'));
    }
    if ($editMode) {
        Yii::import('ext.imperavi-redactor-widget.ImperaviRedactorWidget');
        CController::widget('ImperaviRedactorWidget', ['selector' => '#survContent', 'options' => ['lang' => 'en', 'toolbar' => true, 'buttonSource' => true, 'iframe' => false, 'placeholder' => 'Enter some text...', 'pastePlainText' => true, 'focus' => true, 'imageUpload' => 'imageUpload'], 'plugins' => ['fullscreen' => ['js' => ['fullscreen.js']], 'fontsize' => ['js' => ['fontsize.js']], 'table' => ['js' => ['table.js']], 'imagemanager' => ['js' => ['imagemanager.js']], 'fontcolor' => ['js' => ['fontcolor.js']]]]);
        echo CHtml::form($submitUrl);
        echo CHtml::textArea('survContent', $content->docData);
        echo CHtml::hiddenField('pageId', $content->docId);
        echo CHtml::submitButton(Yii::t('translation', 'Save'));
        echo CHtml::endForm();
    }
}
if (!$editMode) {
    echo urldecode($content->docData);
}