コード例 #1
0
ファイル: RulesAjax.php プロジェクト: jasmun/Noco100
 /**
  * @return IfwPsn_Wp_Ajax_Response_Abstract
  */
 public function getResponse()
 {
     $listTable = new Psn_Admin_ListTable_Rules(IfwPsn_Wp_Plugin_Manager::getInstance('Psn'), array('metabox_embedded' => true, 'ajax' => true));
     if (isset($_POST['refresh_rows'])) {
         $html = $listTable->ajax_response();
     } else {
         $html = '<p><a href="' . IfwPsn_Wp_Proxy_Admin::getUrl() . IfwPsn_Wp_Proxy_Admin::getMenuUrl(IfwPsn_Wp_Plugin_Manager::getInstance('Psn'), 'rules', 'create') . '" class="ifw-wp-icon-plus" id="link_create_rule">' . __('Create new rule', 'psn') . '</a></p>';
         $html .= $listTable->fetch();
     }
     return new IfwPsn_Wp_Ajax_Response_Json(true, array('html' => $html));
 }
コード例 #2
0
ファイル: Handler.php プロジェクト: jasmun/Noco100
 /**
  * Fetch a post on save / update and store it for later processing
  *
  * @param $post_ID
  * @param $post
  * @param $update
  */
 public function fetchPostOnInsert($post_ID, $post, $update = null)
 {
     // fetch post
     $this->_post = $post;
     if (IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->hasOption('psn_late_execution')) {
         // register container execution for shutdown action
         IfwPsn_Wp_Proxy_Action::add('shutdown', array($this, 'execute'));
     } else {
         $this->execute();
     }
 }
コード例 #3
0
ファイル: NotificationRule.php プロジェクト: jasmun/Noco100
 /**
  * @return void
  */
 public function init()
 {
     $this->setMethod('post')->setName('psn_form_rule')->setAttrib('accept-charset', 'utf-8');
     $this->setAttrib('class', 'ifw-wp-zend-form-ul');
     $this->setDecorators(array('FormElements', 'Form'));
     $this->_fieldDecorators = array(new IfwPsn_Zend_Form_Decorator_SimpleInput(), array('HtmlTag', array('tag' => 'li')), 'Errors', 'Description');
     $this->addElement('text', 'name', array('label' => __('Rule name', 'psn'), 'description' => __('Name of the rule', 'psn'), 'required' => true, 'filters' => array(new IfwPsn_Zend_Filter_SanitizeTextField()), 'maxlength' => 80, 'validators' => $_GET['appaction'] == 'create' ? array(new Psn_Admin_Form_Validate_Max()) : array(), 'decorators' => $this->getFieldDecorators(), 'order' => 10));
     $postTypeOptions = array();
     if ($this->isHideNonPublicPostTypes()) {
         $postTypeOptions['public'] = true;
     }
     /**
      * Post Type
      */
     $postType = $this->createElement('select', 'posttype');
     $postTypeOptions = array_merge(array('all' => __('all types', 'psn')), IfwPsn_Wp_Proxy_Post::getAllTypesWithLabels($postTypeOptions));
     unset($postTypeOptions['attachment']);
     unset($postTypeOptions['nav_menu_item']);
     $postType->setLabel(__('Post type', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array(new IfwPsn_Zend_Filter_SanitizeTextField()))->addMultiOptions($postTypeOptions)->setOrder(20);
     $this->addElement($postType);
     /**
      * Post status
      */
     $statusValues = array_merge(array('new' => __('New', 'ifw'), 'not_published' => __('Not published', 'psn'), 'not_private' => __('Not private', 'psn'), 'not_pending' => __('Not pending', 'psn'), 'not_trash' => __('Not trash', 'psn')), IfwPsn_Wp_Proxy_Post::getAllStatusesWithLabels(array('show_domain' => true)));
     natcasesort($statusValues);
     $statusValues = array_merge(array('anything' => __('anything', 'psn')), $statusValues);
     /**
      * Status before
      */
     $statusBefore = $this->createElement('select', 'status_before');
     $statusBefore->setLabel(__('Status before', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array(new IfwPsn_Zend_Filter_SanitizeTextField()))->addMultiOptions($statusValues)->setOrder(30);
     $this->addElement($statusBefore);
     /**
      * Status after
      */
     $statusAfter = $this->createElement('select', 'status_after');
     $statusAfter->setLabel(__('Status after', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array(new IfwPsn_Zend_Filter_SanitizeTextField()))->addMultiOptions($statusValues)->setOrder(40);
     $this->addElement($statusAfter);
     /**
      * Subject
      */
     $this->addElement('text', 'notification_subject', array('label' => __('Subject', 'psn'), 'description' => sprintf(__('Open the help menu in the upper right corner to see a list of all <a %s>supported placeholders</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"') . ' ' . sprintf(__('Supports <a %s>conditions</a> (if activated in the options).', 'psn'), 'href="javascript:void(0)" class="conditions_help"'), 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'maxlength' => 200, 'decorators' => $this->getFieldDecorators(), 'order' => 50));
     $this->getElement('notification_subject')->getDecorator('Description')->setEscape(false);
     /**
      * Body
      */
     $this->addElement('textarea', 'notification_body', array('label' => __('Text', 'psn'), 'description' => sprintf(__('Open the help menu in the upper right corner to see a list of all <a %s>supported placeholders</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"') . ' ' . sprintf(__('Supports <a %s>conditions</a> (if activated in the options).', 'psn'), 'href="javascript:void(0)" class="conditions_help"'), 'validators' => array(new Psn_Admin_Form_Validate_MailBody()), 'required' => false, 'filters' => array('StringTrim', 'HtmlEntities'), 'cols' => 80, 'rows' => 10, 'allowempty' => false, 'decorators' => $this->getFieldDecorators(), 'order' => 60));
     $this->getElement('notification_body')->getDecorator('Description')->setEscape(false);
     /**
      * Recipients
      */
     $recipients = IfwPsn_Wp_Proxy_Filter::apply('psn_rule_form_recipients_options', array('admin' => __('Blog admin', 'psn'), 'author' => __('Post author', 'psn')));
     /**
      * TO
      */
     $recipient = $this->createElement('multiselect', 'recipient');
     $recipient->setLabel(__('Recipient', 'psn'))->setDescription(__('To select multiple recipients hold down the control button (ctrl) on Windows or command button (cmd) on Mac.', 'psn'))->setRequired(false)->setValidators(array(new Psn_Admin_Form_Validate_ToEmail()))->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->setAttrib('size', 10)->addMultiOptions($recipients)->setOrder(70);
     $this->addElement($recipient);
     /**
      * CC
      */
     $cc_select = $this->createElement('multiselect', 'cc_select');
     $cc_select->setLabel(__('CC', 'psn'))->setDescription(__('To select multiple cc recipients hold down the control button (ctrl) on Windows or command button (cmd) on Mac.', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->setAttrib('size', 10)->addMultiOptions($recipients)->setOrder(80);
     $this->addElement($cc_select);
     $this->addElement('textarea', 'cc', array('label' => __('Custom CC', 'psn'), 'description' => IfwPsn_Wp_Proxy_Filter::apply('psn_rule_form_description_cc', sprintf(__('Add additional recipient emails. Comma separated. Supports placeholders like [author_email], [blog_admin_email], [current_user_email] or the dynamic [recipient_*] placeholders. Check the <a %s>placeholders help</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"')), 'filters' => array('StringTrim', 'HtmlEntities', new Psn_Admin_Form_Filter_Cc(IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->isPremium())), 'cols' => 80, 'rows' => 1, 'decorators' => $this->getFieldDecorators(), 'order' => 85));
     $this->getElement('cc')->getDecorator('Description')->setEscape(false);
     /**
      * BCC
      */
     $bcc_select = $this->createElement('multiselect', 'bcc_select');
     $bcc_select->setLabel(__('BCC', 'psn'))->setDescription(__('To select multiple bcc recipients hold down the control button (ctrl) on Windows or command button (cmd) on Mac.', 'psn'))->setDecorators($this->getFieldDecorators())->setFilters(array('StringTrim', 'StripTags'))->setAttrib('size', 10)->addMultiOptions($recipients)->setOrder(90);
     $this->addElement($bcc_select);
     $this->addElement('textarea', 'bcc', array('label' => __('Custom BCC', 'psn'), 'description' => IfwPsn_Wp_Proxy_Filter::apply('psn_rule_form_description_bcc', sprintf(__('Add bcc recipient emails. Comma separated. Supports placeholders like [author_email], [blog_admin_email], [current_user_email] or the dynamic [recipient_*] placeholders. Check the <a %s>placeholders help</a>.', 'psn'), 'href="javascript:void(0)" class="placeholder_help"')), 'escape' => false, 'filters' => array('StringTrim', 'HtmlEntities', new Psn_Admin_Form_Filter_Bcc(IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->isPremium())), 'cols' => 80, 'rows' => 1, 'decorators' => $this->getFieldDecorators(), 'order' => 95));
     $this->getElement('bcc')->getDecorator('Description')->setEscape(false);
     /**
      * Active
      */
     $active = $this->createElement('checkbox', 'active');
     $active->setLabel(__('Active', 'psn'))->setDecorators($this->getFieldDecorators())->setDescription(__('Only active rules take affect on post transition changes', 'psn'))->setChecked(true)->setCheckedValue(1)->setOrder(100);
     $this->addElement($active);
     /**
      * Service email
      */
     $email = $this->createElement('checkbox', 'service_email');
     $email->setLabel(__('Email', 'psn'))->setDecorators($this->getFieldDecorators())->setDescription(__('When the rule matches, an email will be send to the recipient with subject and text', 'psn'))->setChecked(true)->setCheckedValue(1)->setOrder(110);
     $this->addElement($email);
     if (isset($_REQUEST['id'])) {
         $this->addElement('hidden', 'id', array('value' => $_REQUEST['id'], 'decorators' => array('ViewHelper')));
     }
     $this->setNonce('psn-form-rule');
     $this->addElement('note', 'p', array('label' => '-', 'value' => '&nbsp;', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'p'))), 'order' => 999));
     /**
      * Submit button
      */
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => __('Save', 'psn'), 'class' => 'button-primary', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'span'))), 'order' => 1000));
     $this->addElement('note', 'divider', array('label' => '-', 'value' => '&nbsp;&mdash;&nbsp;', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'span'))), 'order' => 1001));
     $this->addElement('submit', 'submit_and_stay', array('ignore' => true, 'label' => __('Save and stay on page', 'psn'), 'class' => 'button', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'span'))), 'order' => 1002));
 }
コード例 #4
0
 /**
  * @param $identifier
  * @param $headline
  * @param $helpUrl
  * @param $actionUrl
  * @return string
  * @throws IfwPsn_Wp_Plugin_Exception
  */
 public static function getImportForm($identifier, $headline, $helpUrl, $actionUrl)
 {
     $helpText = sprintf(__('Need help? <a href="%s" target="_blank">Check the docs</a>.', 'psn'), IfwPsn_Wp_Plugin_Manager::getInstance('Psn')->getConfig()->plugin->docUrl . $helpUrl);
     $options = array('headline' => $headline, 'help_text' => $helpText, 'action_url' => $actionUrl, 'import_file_label' => __('Import file', 'psn'), 'import_file_description' => __('Please select a valid .xml export file.', 'psn'), 'import_prefix_label' => __('Import prefix (optional)', 'psn'), 'import_prefix_description' => __('Prepend this text to imported items names to identify them.', 'psn'), 'wait_text_headline' => __('Processing file', 'psn'), 'wait_text_description' => __('Please wait while the export file is being processed ...', 'psn'));
     return IfwPsn_Wp_Data_Importer::getForm(IfwPsn_Wp_Plugin_Manager::getInstance('Psn'), $identifier, $options);
 }
コード例 #5
0
ファイル: Placeholders.php プロジェクト: jasmun/Noco100
 /**
  * @return string
  */
 public function getOnScreenHelp()
 {
     $this->addPlaceholder('post_status_before')->addPlaceholder('post_status_after');
     $placeholdersResult = $this->getDefaultPlaceholders(true, true);
     asort($placeholdersResult);
     $placeholdersDynamic = $this->getPlaceholders('dynamic');
     asort($placeholdersDynamic);
     $placeholdersArray = $this->getPlaceholders('arrays');
     asort($placeholdersArray);
     $context = array('placeholders' => $placeholdersResult, 'placeholdersDynamic' => $placeholdersDynamic, 'placeholdersArray' => $placeholdersArray);
     return IfwPsn_Wp_WunderScript_Parser::getFileInstance(IfwPsn_Wp_Plugin_Manager::getInstance('Psn'))->parse('admin_help_placeholders.html.twig', $context);
 }