Example #1
0
 protected function setupInheritance()
 {
     parent::setupInheritance();
     $this->widgetSchema->setNameFormat('image[%s]');
 }
 /**
  * Check and set icon for language.
  *
  * @param Language $language Language object.
  * @param FileForm $form     Form object.
  *
  * @return void
  */
 protected function _setLanguageIcon($language, $form)
 {
     // Upload language icon.
     if (!$form->hasFiles()) {
         return;
     }
     if (!is_dir(PUBLIC_PATH . '/' . Language::LANGUAGE_ICON_LOCATION)) {
         mkdir(PUBLIC_PATH . '/' . Language::LANGUAGE_ICON_LOCATION, 766, true);
     }
     $files = $form->getFiles();
     $iconPath = Language::LANGUAGE_ICON_LOCATION . $language->language . ' . ' . pathinfo($files[0]->getName(), PATHINFO_EXTENSION);
     $fullIconPath = PUBLIC_PATH . '/' . $iconPath;
     if (file_exists($fullIconPath)) {
         @unlink($fullIconPath);
     }
     $files[0]->moveTo($fullIconPath);
     $language->icon = $iconPath;
     $language->save();
 }
 /**
  * Save the name attribute for a file
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function saveMetadata($args, &$request)
 {
     $fileId = $request->getUserVar('rowId');
     $name = $request->getUserVar('name');
     $fileType = isset($args['fileType']) ? $args['fileType'] : null;
     import('controllers.grid.settings.library.form.FileForm');
     $fileForm = new FileForm($fileType, $fileId);
     $fileForm->readInputData();
     if ($fileForm->validate()) {
         $libraryFile = $fileForm->execute($args, $request);
         $row =& $this->getRowInstance();
         $row->setGridId($this->getId());
         $row->setId($fileId);
         $row->setData($libraryFile);
         $row->initialize($request);
         $json = new JSON('true', $this->_renderRowInternally($request, $row));
     } else {
         $json = new JSON('false');
     }
     return $json->getString();
 }