public function updateCache()
 {
     if ($action = Q('get.action')) {
         switch ($action) {
             case "Config":
                 $Model = K("Config");
                 $Model->updateCache();
                 $this->success('网站配置更新完毕...', U('updateCache', array('action' => 'Model')), 0);
                 break;
             case "Model":
                 $Model = K("Model");
                 $Model->updateCache();
                 $this->success('模型更新完毕...', U('updateCache', array('action' => 'Field')), 0);
                 break;
             case "Field":
                 $ModelCache = S("model");
                 foreach ($ModelCache as $mid => $data) {
                     $_REQUEST['mid'] = $mid;
                     $Model = new FieldModel();
                     $Model->updateCache($mid);
                 }
                 $this->success('字段更新完毕...', U('updateCache', array('action' => 'Category')), 0);
                 break;
             case "Category":
                 $Model = K('Category');
                 $Model->updateCache();
                 $this->success('栏目更新完毕...', U('updateCache', array('action' => 'Node')), 0);
                 break;
             case "Node":
                 $Model = K("Node");
                 $Model->updateCache();
                 $this->success('权限节点更新完毕...', U('updateCache', array('action' => 'Table')), 0);
                 break;
             case "Table":
                 Dir::del('temp/Table');
                 $this->success('数据表更新完毕...', U('updateCache', array('action' => 'Role')), 0);
                 break;
             case "Role":
                 $Model = K("Role");
                 $Model->updateCache();
                 $this->success('角色更新完毕...', U('updateCache', array('action' => 'Flag')), 0);
                 break;
             case "Flag":
                 $ModelCache = S("model");
                 foreach ($ModelCache as $mid => $data) {
                     $_REQUEST['mid'] = $mid;
                     $Model = new FlagModel();
                     $Model->updateCache();
                 }
                 $this->display('success.php');
                 break;
         }
     } else {
         $this->success('缓存更新成功...', U('index'), 0);
     }
 }
示例#2
0
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $attributes = $field->getAttributes();
     $errorMessage = craft()->sproutFields_emailField->getErrorMessage($attributes['name'], $settings);
     $placeholder = isset($settings['placeholder']) ? $settings['placeholder'] : '';
     $rendered = craft()->templates->render('email/input', array('name' => $field->handle, 'value' => $value, 'field' => $field, 'pattern' => $settings['customPattern'], 'errorMessage' => $errorMessage, 'renderingOptions' => $renderingOptions, 'placeholder' => $placeholder));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
 public function updateCache()
 {
     $actionCache = S('updateCacheAction');
     if ($actionCache) {
         while ($action = array_shift($actionCache)) {
             switch ($action) {
                 case "Config":
                     $Model = K("Config");
                     $Model->updateCache();
                     S('updateCacheAction', $actionCache);
                     $this->success('网站配置更新完毕...', U('updateCache'), 0);
                     break;
                 case "Model":
                     $Model = K("Model");
                     $Model->updateCache();
                     S('updateCacheAction', $actionCache);
                     $this->success('模型更新完毕...', U('updateCache'), 0);
                     break;
                 case "Field":
                     $ModelCache = S("model");
                     foreach ($ModelCache as $mid => $data) {
                         $_REQUEST['mid'] = $mid;
                         $Model = new FieldModel();
                         $Model->updateCache($mid);
                     }
                     S('updateCacheAction', $actionCache);
                     $this->success('字段更新完毕...', U('updateCache'), 0);
                     break;
                 case "Category":
                     $Model = K('Category');
                     $Model->updateCache();
                     S('updateCacheAction', $actionCache);
                     $this->success('栏目更新完毕...', U('updateCache'), 0);
                     break;
                 case "Flag":
                     $ModelCache = S("model");
                     foreach ($ModelCache as $mid => $data) {
                         $_REQUEST['mid'] = $mid;
                         $Model = new FlagModel();
                         $Model->updateCache();
                     }
                     S('updateCacheAction', $actionCache);
                     $this->success('Flag属性更新完毕...', U('updateCache'), 0);
                     break;
             }
         }
         go('updateCache');
     } else {
         S('updateCacheAction', null);
         $this->success('缓存更新成功...<script>setTimeout(function(){top.location.href="' . __MODULE__ . '"},2000);</script>', U('index'));
     }
 }
示例#4
0
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $name = $field->handle;
     $namespaceInputId = $this->getNamespace() . '-' . $name;
     $pattern = craft()->sproutFields_phoneField->convertMaskToRegEx($settings['mask']);
     $pattern = trim($pattern, '/');
     $attributes = $field->getAttributes();
     $errorMessage = craft()->sproutFields_phoneField->getErrorMessage($attributes['name'], $settings);
     $rendered = craft()->templates->render('phone/input', array('name' => $name, 'value' => $value, 'settings' => $settings, 'field' => $field, 'pattern' => $pattern, 'errorMessage' => $errorMessage, 'namespaceInputId' => $namespaceInputId, 'renderingOptions' => $renderingOptions));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
示例#5
0
 /**
  * 添加模型
  */
 public function addModel()
 {
     Q('model_name', '', 'trim');
     Q('table_name', '', 'strtolower,trim');
     $this->validate = array(array('model_name', 'nonull', '模型名称不能为空', 2, 1), array('table_name', 'nonull', '表名不能为空', 2, 1));
     //验证表是否存在
     if ($this->tableExists($_POST['table_name'])) {
         $this->error = '数据表已经存在';
         return false;
     }
     //验证模型名称验证
     if (M('model')->find(array('model_name' => $_POST['model_name']))) {
         $this->error = '模型已经存在';
         return false;
     }
     //创建模型表
     if ($this->create()) {
         $table_name = $this->data['table_name'];
         if ($this->createModelSql($table_name)) {
             //向模型表添加模型信息
             $mid = $this->add();
             if ($mid) {
                 //创建Field表信息(初始模型字段)
                 $db = M();
                 $db_prefix = C("DB_PREFIX");
                 $table = $table_name;
                 require MODULE_PATH . '/Data/ModelSql/FieldInit.php';
                 if ($this->updateCache()) {
                     //更新字段缓存
                     $_REQUEST['mid'] = $mid;
                     $ModelField = new FieldModel();
                     $ModelField->updateCache();
                     //更新文章属性缓存
                     $FlagModel = new FlagModel();
                     $FlagModel->updateCache();
                     return $mid;
                 }
             } else {
                 return false;
             }
         }
     }
 }
 public function import($fields)
 {
     $fieldTypes = craft()->fields->getAllFieldTypes();
     $errors = array();
     foreach ($fields as $fieldInfo) {
         if (array_key_exists($fieldInfo['type'], $fieldTypes)) {
             $field = new FieldModel();
             $field->setAttributes(array('groupId' => $fieldInfo['groupId'], 'name' => $fieldInfo['name'], 'handle' => $fieldInfo['handle'], 'instructions' => $fieldInfo['instructions'], 'translatable' => $fieldInfo['translatable'], 'required' => $fieldInfo['required'], 'type' => $fieldInfo['type'], 'settings' => $fieldInfo['settings']));
             // Send off to Craft's native fieldSave service for heavy lifting.
             if (craft()->fields->saveField($field)) {
                 FieldManagerPlugin::log($field->name . ' imported successfully.');
             } else {
                 $errors[$fieldInfo['handle']] = $field;
                 FieldManagerPlugin::log('Could not import ' . $field->name . ' - ' . print_r($field->getErrors(), true), LogLevel::Error);
             }
         }
     }
     return $errors;
 }
 public function import($fieldDefs)
 {
     $fields = craft()->fields->getAllFields('handle');
     $fieldTypes = craft()->fields->getAllFieldTypes();
     foreach ($fieldDefs as $fieldHandle => $fieldDef) {
         if (array_key_exists($fieldDef['type'], $fieldTypes)) {
             $field = new FieldModel();
             $field->setAttributes(array('handle' => $fieldHandle, 'groupId' => $fieldDef['groupId'], 'name' => $fieldDef['name'], 'context' => $fieldDef['context'], 'instructions' => $fieldDef['instructions'], 'translatable' => $fieldDef['translatable'], 'type' => $fieldDef['type'], 'settings' => $fieldDef['settings']));
             if ($field->type == 'PositionSelect') {
                 $this->handlePositionSelect($fieldDef, $field);
             }
             if (!craft()->fields->saveField($field)) {
                 return $field->getAllErrors();
             }
             if ($field->type == 'Matrix') {
                 $this->handleMatrixImport($fieldDef, $field);
             }
             if ($field->type == 'SuperTable') {
                 $this->handleSuperTableImport($fieldDef, $field);
             }
         }
     }
     return true;
 }
 public function edit()
 {
     if (IS_POST) {
         $Model = FieldModel::getInstance();
         if ($Model->editField()) {
             $this->success('修改成功');
         } else {
             $this->error($Model->error);
         }
     } else {
         $fid = Q('fid', 0, 'intval');
         $data = M('field')->where("fid={$fid}")->find();
         $field = $this->field[$data['field_name']];
         $this->assign('field', $field);
         /**
          * 字段set值模板
          * 依赖上面分配的field值
          */
         $setField = $this->fetch(CONTROLLER_VIEW_PATH . "Data/{$data['field_type']}/edit");
         $this->assign('setField', $setField);
         $this->assign('model_name', $this->model[$this->mid]['model_name']);
         $this->display();
     }
 }
 /**
  * Checks whether the given field is saving data into a textual column, and saves it accordingly.
  *
  * @param FieldModel $field
  * @param string     $fieldColumnPrefix
  *
  * @return bool
  */
 private function _checkField(FieldModel $field, $fieldColumnPrefix)
 {
     if ($field->type == 'Matrix') {
         $this->_matrixFieldIds[] = $field->id;
     } else {
         $fieldType = $field->getFieldType();
         if ($fieldType) {
             $attributeConfig = $fieldType->defineContentAttribute();
             if ($attributeConfig && $attributeConfig != AttributeType::Number) {
                 $attributeConfig = ModelHelper::normalizeAttributeConfig($attributeConfig);
                 if ($attributeConfig['type'] == AttributeType::String) {
                     $this->_textColumns[] = $fieldColumnPrefix . $field->handle;
                 }
             }
         }
     }
 }
示例#10
0
 /**
  * Populates a fieldtype.
  *
  * @param FieldModel            $field
  * @param BaseElementModel|null $element
  *
  * @return BaseFieldType|null
  */
 public function populateFieldType(FieldModel $field, $element = null)
 {
     $fieldType = $field->getFieldType();
     if ($fieldType) {
         $fieldType->element = $element;
         return new FieldTypeVariable($fieldType);
     }
 }
 /**
  * Upload files for an Asset field.
  *
  * @param FieldModel              $field
  * @param AmForms_SubmissionModel &$submission
  * @param array                   $fieldsContent
  */
 private function _uploadFilesForField($field, &$submission, $fieldsContent)
 {
     $uploadedFiles = array();
     // Get folder
     $folderId = $field->getFieldType()->resolveSourcePath();
     // Single file upload
     if (!empty($_FILES[$field->handle]['name'])) {
         // Upload file
         $file = $_FILES[$field->handle];
         $fileId = $this->_uploadFile($file, $folderId);
         if (is_numeric($fileId)) {
             $uploadedFiles[] = $fileId;
         }
     }
     // Multi file upload
     if (isset($fieldsContent['filesNames']) && isset($fieldsContent['filesNames'][$field->handle])) {
         foreach ($fieldsContent['filesNames'][$field->handle] as $fileName) {
             foreach ($_FILES as $key => $possibleFile) {
                 if (isset($possibleFile['name']) && $possibleFile['name'] == $fileName) {
                     // Upload file
                     $fileId = $this->_uploadFile($possibleFile, $folderId);
                     if (is_numeric($fileId)) {
                         $uploadedFiles[] = $fileId;
                         // Remove from $_FILES so we can't find again if we have more than one multiple file upload field
                         unset($_FILES[$key]);
                     }
                 }
             }
         }
     }
     // Add files to submission
     $submission->getContent()->setAttribute($field->handle, $uploadedFiles);
 }
 /**
  * @param array $fieldDefinition
  * @param FieldModel $field
  * @param string $fieldHandle
  * @param FieldGroupModel $group
  */
 private function populateField(array $fieldDefinition, FieldModel $field, $fieldHandle, FieldGroupModel $group = null)
 {
     $field->name = $fieldDefinition['name'];
     $field->handle = $fieldHandle;
     $field->required = $fieldDefinition['required'];
     $field->translatable = $fieldDefinition['translatable'];
     $field->instructions = $fieldDefinition['instructions'];
     $field->type = $fieldDefinition['type'];
     $field->settings = $fieldDefinition['settings'];
     if ($group) {
         $field->groupId = $group->id;
     }
     if ($field->type == 'Entries') {
         $settings = $fieldDefinition['settings'];
         $settings['sources'] = $this->getSourceIds($settings['sources']);
         $field->settings = $settings;
     }
     if ($field->type == 'Matrix') {
         $field->settings = $field->getFieldType()->getSettings();
         $field->settings->setAttributes($fieldDefinition['settings']);
         $field->settings->setBlockTypes($this->getBlockTypes($fieldDefinition, $field));
     }
 }
示例#13
0
 /**
  * Deletes a field by its ID.
  *
  * @param int $fieldId
  * @return bool
  */
 public function deleteFieldById($fieldId)
 {
     $fieldRecord = FieldRecord::model()->findById($fieldId);
     if (!$fieldRecord) {
         return false;
     }
     $field = FieldModel::populateModel($fieldRecord);
     return $this->deleteField($field);
 }
 /**
  * Returns a field record for a given model.
  *
  * @param FieldModel $field
  *
  * @throws Exception
  * @return FieldRecord
  */
 private function _getFieldRecord(FieldModel $field)
 {
     if (!$field->isNew()) {
         $fieldId = $field->id;
         if (!isset($this->_fieldRecordsById) || !array_key_exists($fieldId, $this->_fieldRecordsById)) {
             $this->_fieldRecordsById[$fieldId] = FieldRecord::model()->findById($fieldId);
             if (!$this->_fieldRecordsById[$fieldId]) {
                 throw new Exception(Craft::t('No field exists with the ID “{id}”.', array('id' => $fieldId)));
             }
         }
         return $this->_fieldRecordsById[$fieldId];
     } else {
         return new FieldRecord();
     }
 }
示例#15
0
 function afterFind($results)
 {
     if (empty($results)) {
         return $results;
     }
     $sumRatings = array();
     # Add Community Builder info to results array
     if (!defined('MVC_FRAMEWORK_ADMIN') && class_exists('CommunityModel')) {
         $Community = ClassRegistry::getClass('CommunityModel');
         $results = $Community->addProfileInfo($results, 'User', 'user_id');
     }
     # Add custom field info to results array
     App::import('Model', 'field', 'jreviews');
     $CustomFields = new FieldModel();
     $results = $CustomFields->addFields($results, 'review');
     # Preprocess criteria and rating information
     if ($this->runProcessRatings) {
         $results = $this->processRatings($results);
     }
     return $results;
 }
 /**
  * @param string     $data
  * @param FieldModel $field
  *
  * @return array
  */
 private function prepEntriesFieldType($data, FieldModel $field)
 {
     // Get field settings
     $settings = $field->getFieldType()->getSettings();
     // Get source id's for connecting
     $sectionIds = array();
     $sources = $settings->getAttribute('sources');
     if (is_array($sources)) {
         foreach ($sources as $source) {
             list($type, $id) = explode(':', $source);
             $sectionIds[] = $id;
         }
     }
     // Find matching element in sections
     $criteria = craft()->elements->getCriteria(ElementType::Entry);
     $criteria->sectionId = $sectionIds;
     $criteria->limit = $settings->limit;
     // Get search strings
     $search = ArrayHelper::stringToArray($data);
     // Ability to import multiple Assets at once
     $data = array();
     // Loop through keywords
     foreach ($search as $query) {
         // Search
         $criteria->search = $query;
         // Add to data
         $data = array_merge($data, $criteria->ids());
     }
     return $data;
 }
 public function safeUp()
 {
     $plugin = craft()->plugins->getPlugin('fruitlinkit');
     // Firstly lets check if we have any existing Link It fields
     $query = craft()->db->createCommand()->select('*')->from('fields')->where('type = :fruitlinkit OR type = :linkit', array('fruitlinkit' => 'FruitLinkIt_LinkIt', 'linkit' => 'Linkit_Linkit'))->queryAll();
     // Now lets update any existing Link It fields to the new settings structure
     $fields = FieldModel::populateModels($query);
     if ($fields) {
         // Build new default types string
         $sources = craft()->fruitLinkIt->getLinkItElementSources();
         $defaultTypes = array('email', 'tel', 'custom');
         if ($sources['entry']) {
             array_push($defaultTypes, 'entry');
         }
         if ($sources['category']) {
             array_push($defaultTypes, 'category');
         }
         if ($sources['asset']) {
             array_push($defaultTypes, 'asset');
         }
         $defaultSettings = array('types' => $defaultTypes, 'defaultText' => '', 'allowCustomText' => false, 'allowTarget' => false, 'entrySources' => '*', 'entrySelectionLabel' => 'Select an entry', 'assetSources' => '*', 'assetSelectionLabel' => 'Select an asset', 'categorySources' => '*', 'categorySelectionLabel' => 'Select a category');
         foreach ($fields as $field) {
             $existingSettings = $field->settings;
             $settings = $defaultSettings;
             // Changed: Asset Sources
             if (array_key_exists('assetSources', $existingSettings)) {
                 $settings['assetSources'] = $existingSettings['assetSources'];
             }
             // Changed: Entry Sources
             if (array_key_exists('entrySources', $existingSettings)) {
                 $settings['entrySources'] = $existingSettings['entrySources'];
             }
             // Changed: Types
             if ($existingSettings['types'] != '*') {
                 $settings['types'] = $existingSettings['types'];
             }
             // Changed: Allow Target
             if (array_key_exists('allowTarget', $existingSettings)) {
                 $settings['allowTarget'] = $existingSettings['allowTarget'];
             } elseif (array_key_exists('target', $existingSettings)) {
                 $settings['allowTarget'] = $existingSettings['target'];
             }
             // Changed: Default Text
             if (array_key_exists('defaultText', $existingSettings)) {
                 $settings['defaultText'] = $existingSettings['defaultText'];
             }
             // Changed: Allow Custom Text
             if (array_key_exists('allowCustomText', $existingSettings)) {
                 $settings['allowCustomText'] = $existingSettings['allowCustomText'];
             } elseif (array_key_exists('text', $existingSettings)) {
                 $settings['allowCustomText'] = $existingSettings['text'];
             }
             // Changed: Category Sources
             if (array_key_exists('categorySources', $existingSettings)) {
                 $settings['categorySources'] = $existingSettings['categorySources'];
             }
             // Changed: Entry Selection Label
             if (array_key_exists('entrySelectionLabel', $existingSettings)) {
                 $settings['entrySelectionLabel'] = $existingSettings['entrySelectionLabel'];
             }
             // Changed: Category Selection Label
             if (array_key_exists('categorySelectionLabel', $existingSettings)) {
                 $settings['categorySelectionLabel'] = $existingSettings['categorySelectionLabel'];
             }
             // Changed: Asset Selection Label
             if (array_key_exists('assetSelectionLabel', $existingSettings)) {
                 $settings['assetSelectionLabel'] = $existingSettings['assetSelectionLabel'];
             }
             // Update
             $data = array('settings' => JsonHelper::encode($settings));
             if (craft()->db->createCommand()->update('fields', $data, 'id = :id', array(':id' => $field->id))) {
                 FruitLinkItPlugin::log('Updated field to latest schema: ' . $field->id);
             } else {
                 FruitLinkItPlugin::log('Could not update field id: ' . $field->id, LogLevel::Error);
             }
         }
         // Uupdate any old version fields fieldtype
         craft()->db->createCommand()->update('fields', ['type' => 'FruitLinkIt'], 'type=:fieldType', [':fieldType' => 'FruitLinkIt_LinkIt']);
         craft()->db->createCommand()->update('fields', ['type' => 'FruitLinkIt'], 'type=:fieldType', [':fieldType' => 'Linkit_Linkit']);
     }
     // Now delete the old version
     craft()->db->createCommand()->delete('plugins', "class = 'Linkit'");
     return true;
 }
 function _installfix()
 {
     // Load fields model
     App::import('Model', 'field', 'jreviews');
     $FieldModel = new FieldModel();
     $task = Sanitize::getString($this->data, 'task');
     $msg = '';
     $mambot_error = 0;
     switch ($task) {
         case 'fix_install_jreviews':
             if (!$this->_installPlugin()) {
                 $msg = "There was a problem updating the database or copying the plugin files. Make sure the Joomla plugins/content folder is writable.";
             }
             break;
         case 'fix_content_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_content'));
             $columns = array_keys($rows['#__jreviews_content']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'content'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'content');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the content fields";
             }
             break;
         case 'fix_review_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_review_fields'));
             $columns = array_keys($rows['#__jreviews_review_fields']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'review'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'review');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the review fields";
             }
             break;
         default:
             break;
     }
     cmsFramework::redirect("index.php?option=com_jreviews", $msg);
 }
示例#19
0
 function _installfix()
 {
     // Load fields model
     App::import('Model', 'field', 'jreviews');
     $FieldModel = new FieldModel();
     $task = Sanitize::getString($this->data, 'task');
     $msg = '';
     $mambot_error = 0;
     switch ($task) {
         case 'fix_install_jreviews':
             $query = "SELECT id,published FROM #__" . _PLUGIN_DIR_NAME . " WHERE element = 'jreviews' AND folder = 'content'";
             $this->_db->setQuery($query);
             $jReviewsMambot = $this->_db->loadObjectList();
             if (!$jReviewsMambot || empty($jReviewsMambot)) {
                 // Install in DB
                 $this->_db->setQuery("INSERT INTO #__" . _PLUGIN_DIR_NAME . " (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES ('jReviews Comment Plugin', 'jreviews', 'content', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '');");
                 $this->_db->query();
             } else {
                 // Publish
                 $jReviewsMambot = $jReviewsMambot[0];
                 if (!$jReviewsMambot->published) {
                     $this->_db->setQuery("UPDATE #__" . _PLUGIN_DIR_NAME . " SET published = '1' WHERE id='{$jReviewsMambot->id}'");
                     $this->_db->query();
                 }
             }
             if (!file_exists(PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content' . DS . 'jreviews.php')) {
                 $package = PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_jreviews' . DS . 'jreviews.plugin.s2';
                 $target = PATH_ROOT . _PLUGIN_DIR_NAME . DS . 'content';
                 $target_file = $target . DS . 'jreviews.php';
                 if (getCmsVersion() == CMS_JOOMLA15) {
                     jimport('joomla.filesystem.file');
                     jimport('joomla.filesystem.folder');
                     jimport('joomla.filesystem.archive');
                     jimport('joomla.filesystem.path');
                     $adapter =& JArchive::getAdapter('zip');
                     $result = $adapter->extract($package, $target);
                 }
                 if (!file_exists($target_file)) {
                     require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
                     require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
                     $extract = new PclZip($package);
                     if (substr(PHP_OS, 0, 3) == 'WIN') {
                         if (!defined('OS_WINDOWS')) {
                             define('OS_WINDOWS', 1);
                         }
                     } else {
                         if (!defined('OS_WINDOWS')) {
                             define('OS_WINDOWS', 0);
                         }
                     }
                     $result = $extract->extract(PCLZIP_OPT_PATH, $target);
                 }
                 if (!$result) {
                     $mambot_error = true;
                 } else {
                     $mambot_error = false;
                 }
             }
             if ($mambot_error) {
                 $msg = "It was not possible to copy the mambot/plugin files. Make sure the /" . _PLUGIN_DIR_NAME . "/content folder is writable and try again.";
             }
             break;
         case 'fix_content_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_content'));
             $columns = array_keys($rows['#__jreviews_content']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'content'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'content');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the content fields";
             }
             break;
         case 'fix_review_fields':
             $output = '';
             $rows = $this->_db->getTableFields(array('#__jreviews_review_fields'));
             $columns = array_keys($rows['#__jreviews_review_fields']);
             $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'review'";
             $this->_db->setQuery($sql);
             $fields = $this->_db->loadObjectList('name');
             $missing = array();
             foreach ($fields as $field) {
                 if (!in_array($field->name, $columns)) {
                     $output = $FieldModel->addTableColumn($field->name, $field->type, 'review');
                 }
             }
             $query = "DELETE FROM #__jreviews_fields WHERE name = ''";
             $this->_db->setQuery($query);
             $output = $this->_db->query();
             if ($output != '') {
                 $msg = "There was a problem fixing one or more of the review fields";
             }
             break;
         default:
             break;
     }
     cmsFramework::redirect("index.php?option=com_jreviews", $msg);
 }