Exemplo n.º 1
0
 public function formatFormOutput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     $column = $model->getColumn($key);
     if (!$column) {
         return null;
     }
     $fieldId = $column['customfield']->id;
     $findParams = \GO\Base\Db\FindParams::newInstance()->select('COUNT(*) AS count')->single()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('model_id', $model->model_id)->addCondition('field_id', $fieldId));
     $model = \GO\Site\Model\MultifileFile::model()->find($findParams);
     $string = '';
     $string = sprintf(\GO::t('multifileSelectValue', 'site'), $model->count);
     return $string;
 }
Exemplo n.º 2
0
 /**
  * Save the sort of the multifiles
  * 
  * @param array $params
  * @throws \GO\Base\Exception
  */
 public function actionSaveSort($params)
 {
     if (!isset($params['sort'])) {
         throw new \GO\Base\Exception('Failed to save the sort.');
     }
     $sortOrder = json_decode($params['sort']);
     foreach ($sortOrder as $order) {
         $file = \GO\Site\Model\MultifileFile::model()->findByPk(array('model_id' => $order->model_id, 'field_id' => $order->field_id, 'file_id' => $order->file_id));
         if (!$file) {
             continue;
         }
         $file->order = $order->sort_index;
         $file->save();
     }
     echo $this->renderJson(array('success' => true));
 }