Exemple #1
0
 /**
  * @param \Ip\Form $form
  * @return mixed
  */
 public static function ipPagePropertiesForm($form, $info)
 {
     $value = ipPageStorage($info['pageId'])->get('PagePassword');
     $fieldset = new \Ip\Form\Fieldset(__('Password', 'PagePassword', false));
     $form->addFieldset($fieldset);
     $form->addField(new \Ip\Form\Field\Text(array('name' => 'pagePassword', 'label' => __('Password', 'PagePassword', false), 'note' => __('Set password to protect page from guest visitors.', 'PagePassword', false), 'value' => $value)));
     return $form;
 }
Exemple #2
0
 /**
  * @param \Ip\Form $form
  * @param array $postData
  * @param array $data
  */
 public function sendEmail($form, $postData, $data)
 {
     $contentData = array();
     $websiteName = ipGetOptionLang('Config.websiteTitle');
     $websiteEmail = ipGetOptionLang('Config.websiteEmail');
     $from = $websiteEmail;
     $files = array();
     foreach ($form->getFields() as $field) {
         if ($field->getType() == \Ip\Form\Field::TYPE_REGULAR) {
             if (!isset($postData[$field->getName()])) {
                 $postData[$field->getName()] = null;
             }
             $title = $field->getLabel();
             $value = $field->getValueAsString($postData, $field->getName());
             $contentData[] = array('fieldClass' => get_class($field), 'title' => $title, 'value' => $value);
         }
         if (get_class($field) == 'Ip\\Form\\Field\\Email') {
             $userFrom = $field->getValueAsString($postData, $field->getName());
             if ($userFrom != '') {
                 $from = $userFrom;
             }
         }
         if (get_class($field) == 'Ip\\Form\\Field\\File') {
             $uploadedFiles = $field->getFiles($postData, $field->getName());
             $originalNames = $field->originalFileNames($postData, $field->getName());
             foreach ($uploadedFiles as $key => $uploadedFile) {
                 $files[] = array($uploadedFile, $originalNames[$key]);
             }
         }
     }
     $content = ipView('helperView/email_content.php', array('values' => $contentData))->render();
     $emailData = array('content' => $content);
     $email = ipEmailTemplate($emailData);
     //get page where this widget sits :)
     $fullWidgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($postData['widgetId']);
     $pageTitle = '';
     if (isset($fullWidgetRecord['revisionId'])) {
         $revision = \Ip\Internal\Revision::getRevision($fullWidgetRecord['revisionId']);
         if (!empty($revision['pageId'])) {
             $pageTitle = ipPage($revision['pageId'])->getTitle();
         }
     }
     $subject = $websiteName . ': ' . $pageTitle;
     $emailQueue = new \Ip\Internal\Email\Module();
     if (!empty($data['sendTo']) && $data['sendTo'] == 'custom') {
         if (empty($data['emails'])) {
             $data['emails'] = '';
         }
         $emailList = preg_split("/[\\s,]+/", $data['emails']);
     } else {
         $emailList = array($websiteEmail);
     }
     foreach ($emailList as $listItem) {
         $emailQueue->addEmail($from, '', $listItem, '', $subject, $email, false, true, $files);
     }
     $emailQueue->send();
 }
Exemple #3
0
 /**
  * @param \Ip\Form $form
  * @return mixed
  */
 public static function ipPagePropertiesForm($form, $info)
 {
     $values = array();
     $current = ipPageStorage($info['pageId'])->get('rssFeed');
     $fieldset = new \Ip\Form\Fieldset(__('RSS', 'rssFeed', false));
     $form->addFieldset($fieldset);
     $form->addField(new \Ip\Form\Field\Checkbox(array('name' => 'rssFeed', 'label' => 'Add to RSS feed', 'value' => $current)));
     return $form;
 }
Exemple #4
0
 /**
  * @param \Ip\Form $form
  * @return mixed
  */
 public static function ipPagePropertiesForm($form, $info)
 {
     $values = array();
     $current = ipPageStorage($info['pageId'])->get('PageImage');
     if (is_array($current)) {
         foreach ($current as $item) {
             if (is_string($item)) {
                 $values[] = $item;
             }
         }
     }
     $fieldset = new \Ip\Form\Fieldset(__('Images', 'PageImage', false));
     $form->addFieldset($fieldset);
     $form->addField(new \Ip\Form\Field\RepositoryFile(array('name' => 'pageImage', 'label' => '', 'preview' => 'thumbnails', 'value' => $values)));
     return $form;
 }
Exemple #5
0
 public static function pluginPropertiesForm($pluginName)
 {
     $form = new \Ip\Form();
     $form->setEnvironment(\Ip\Form::ENVIRONMENT_ADMIN);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'aa', 'value' => 'Plugins.updatePlugin'));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'pluginName', 'value' => $pluginName));
     $form->addField($field);
     $initialFieldCount = count($form->getFields());
     $form = ipFilter('ipPluginPropertiesForm', $form, array('pluginName' => $pluginName));
     if (count($form->getFields()) == $initialFieldCount) {
         return null;
     }
     $field = new \Ip\Form\Field\Submit(array('value' => __('Save', 'Ip-admin')));
     $field->addClass('ipsSave');
     $form->addField($field);
     return $form;
 }
 /**
  * @param \Ip\Form $form
  * @return mixed
  */
 public static function ipPagePropertiesForm($form, $info)
 {
     $requiredFields = array('title' => '', 'description' => '', 'images' => array());
     $tags = Service::facebookTags($info['pageId']);
     $tags = array_merge($requiredFields, $tags);
     $fieldset = new \Ip\Form\Fieldset(__('Facebook meta tags', 'FacebookTags', false));
     $form->addFieldset($fieldset);
     $form->addField(new \Ip\Form\Field\Text(array('name' => 'facebookTagTitle', 'label' => __('Title', 'FacebookTags', false), 'value' => $tags['title'])));
     $form->addField(new \Ip\Form\Field\Text(array('name' => 'facebookTagDescription', 'label' => __('Description', 'FacebookTags', false), 'value' => $tags['description'])));
     $form->addField(new \Ip\Form\Field\RepositoryFile(array('name' => 'facebookTagImages', 'label' => __('Images', 'FacebookTags', false), 'preview' => 'thumbnails', 'value' => $tags['images'])));
     return $form;
 }
Exemple #7
0
 /**
  * @param string $name
  * @return \Ip\Form
  * @throws \Ip\Exception
  */
 public function getThemeConfigForm($name)
 {
     $model = Model::instance();
     $theme = $model->getTheme($name);
     if (!$theme) {
         throw new \Ip\Exception("Theme doesn't exist");
     }
     $form = new \Ip\Form();
     $form->setEnvironment(\Ip\Form::ENVIRONMENT_ADMIN);
     $form->addClass('ipsForm');
     $options = $theme->getOptions();
     $generalFieldset = $this->getFieldset($name, $options);
     $generalFieldset->setLabel(__('General options', 'Ip-admin'));
     if (count($generalFieldset->getFields())) {
         $form->addFieldset($generalFieldset);
     }
     foreach ($options as $option) {
         if (empty($option['type']) || empty($option['options'])) {
             continue;
         }
         if ($option['type'] != 'group') {
             continue;
         }
         $fieldset = $this->getFieldset($name, $option['options']);
         if (!empty($option['label'])) {
             $fieldset->setLabel($option['label']);
         }
         $form->addFieldset($fieldset);
     }
     $form->addFieldset(new \Ip\Form\Fieldset());
     $field = new Form\Field\Hidden();
     $field->setName('aa');
     $field->setValue('Design.updateConfig');
     $form->addField($field);
     return $form;
 }
Exemple #8
0
 /**
  * @param string $pluginName
  * @param \Ip\Form $form
  * @param array $options
  */
 public static function getOptionsForm($pluginName, $form, $options)
 {
     foreach ($options as $option) {
         if (empty($option['type'])) {
             $option['type'] = 'text';
         }
         if (in_array($option['type'], array('select', 'text', 'textarea', 'richText', 'color', 'range', 'checkbox', 'password'))) {
             $option['type'] = ucfirst($option['type']);
         }
         $className = $option['type'];
         if (class_exists($className)) {
             $newField = new $className($option);
         } else {
             $className = 'Ip\\Form\\Field\\' . $option['type'];
             if (class_exists($className)) {
                 $newField = new $className($option);
             }
         }
         if (!isset($newField)) {
             //field type is not recognised
             continue;
         }
         $default = isset($option['default']) ? $option['default'] : null;
         if (!empty($option['name'])) {
             $newField->setName($option['name']);
             $optionKey = "{$pluginName}.{$option['name']}";
             if ($newField instanceof \Ip\Form\FieldLang) {
                 $value = array();
                 foreach (ipContent()->getLanguages() as $language) {
                     $value[$language->getCode()] = ipGetOptionLang($optionKey, $language->getCode(), $default);
                 }
                 $newField->setValue($value);
             } else {
                 $newField->setValue(ipGetOption($optionKey, $default));
             }
         }
         $newField->setLabel(empty($option['label']) ? '' : $option['label']);
         if (!empty($option['note'])) {
             $newField->setNote($option['note']);
         }
         if (!empty($option['validators'])) {
             $newField->addValidator($option['validators']);
         }
         $form->addfield($newField);
     }
 }