protected static function createWidget($layoutKey, $profile, $widgetType = 'profile', $options = array())
 {
     list($widgetClass, $widgetUID) = SortableWidget::parseWidgetLayoutKey($layoutKey);
     return Yii::app()->controller->createWidget('application.components.sortableWidget.' . $widgetClass, array_merge(array('widgetUID' => $widgetUID, 'profile' => $profile, 'widgetType' => $widgetType), $options));
 }
Beispiel #2
0
 /**
  * Instantiates the widget
  * @param string $widgetLayoutKey Key in widget layout associative array. Contains the widget
  *  class name as well as the uid
  * @param object profile
  */
 public static function instantiateWidget($widgetLayoutKey, $profile, $widgetType = 'profile', $options = array())
 {
     list($widgetClass, $widgetUID) = SortableWidget::parseWidgetLayoutKey($widgetLayoutKey);
     if ($widgetClass::getJSONProperty($profile, 'softDeleted', $widgetType, $widgetUID)) {
         return;
     }
     return Yii::app()->controller->widget('application.components.sortableWidget.' . $widgetClass, array_merge(array('widgetUID' => $widgetUID, 'profile' => $profile, 'widgetType' => $widgetType), $options));
 }
Beispiel #3
0
 /**
  * Called to retieve widget contents
  * Expected POST data:
  *  widgetClass - the name of the widget class
  * Echoes:
  *  'failure' if the request action fails, an HTML string containing the widget contents 
  *      otherwise
  */
 public function actionShowWidgetContents()
 {
     if (!isset($_POST['widgetClass']) || !isset($_POST['widgetType'])) {
         echo 'failure';
         return;
     }
     if (isset($_POST['widgetType']) && SortableWidget::getParentType($_POST['widgetType']) === 'recordView' && (!isset($_POST['modelId']) || !isset($_POST['modelType']))) {
         echo 'failure';
         return;
     }
     $profile = self::getModelFromPost();
     $widgetKey = $_POST['widgetClass'];
     $widgetType = $_POST['widgetType'];
     list($widgetClass, $widgetUID) = SortableWidget::parseWidgetLayoutKey($widgetKey);
     if ($profile && class_exists($widgetClass)) {
         if ($widgetClass::setJSONProperty($profile, 'hidden', 0, $widgetType, $widgetUID)) {
             if (SortableWidget::getParentType($widgetType) === 'recordView') {
                 $model = X2Model::getModelOfTypeWithId($_POST['modelType'], $_POST['modelId']);
                 if ($model !== null && $model instanceof X2Model) {
                     echo $widgetClass::getWidgetContents($this, $profile, $widgetType, $widgetUID, array('model' => $model));
                 }
             } else {
                 echo $widgetClass::getWidgetContents($this, $profile, $widgetType, $widgetUID);
             }
             return;
         }
     }
     echo 'failure';
     return;
 }