/** * @param IfwPsn_Wp_Plugin_Manager $pm * @param $identifier * @param array $options * @return string */ public static function getForm(IfwPsn_Wp_Plugin_Manager $pm, $identifier, $options = array()) { $context = array('identifier' => $identifier, 'headline' => $options['headline'], 'help_text' => $options['help_text'], 'action_url' => $options['action_url'], 'import_file_label' => $options['import_file_label'], 'import_file_description' => $options['import_file_description'], 'import_prefix_label' => $options['import_prefix_label'], 'import_prefix_description' => $options['import_prefix_description'], 'wait_text_headline' => $options['wait_text_headline'], 'wait_text_description' => $options['wait_text_description'], 'nonce' => wp_create_nonce(IfwPsn_Zend_Controller_ModelBinding::getImportNonceAction($identifier))); return IfwPsn_Wp_Tpl::getFilesytemInstance($pm)->render('import_form.html.twig', $context); }
/** * @param array $options */ public function handleCopy(array $options = array()) { $id = (int) $this->getRequest()->get('id'); if (!wp_verify_nonce($this->getRequest()->get('nonce'), IfwPsn_Zend_Controller_ModelBinding::getCopyNonceAction($this->getModelMapper()->getSingular(), $id))) { // verification failed $this->getAdminNotices()->persistError($this->getInvalidAccessMessage()); } else { // valid access $item = IfwPsn_Wp_ORM_Model::factory($this->getModelName())->find_one($id); if ($item instanceof IfwPsn_Wp_ORM_Model) { $itemName = $item->getName(); } else { $itemName = ''; } $options = array_merge(array('name_format' => '%s_%s%s'), $options); $result = IfwPsn_Wp_ORM_Model::duplicate($this->getModelName(), $id, $options); if (!empty($result)) { $this->getAdminNotices()->persistUpdated($this->getCopySuccessMessage($itemName)); } else { $this->getAdminNotices()->persistError($this->getCopyErrorMessage($itemName)); } } $this->gotoIndex(); }
public function init() { parent::init(); $this->_pm->getLogger()->logPrefixed('Init controller ' . get_class($this)); }
/** * Custom column handling for name * * @param unknown_type $item * @return string */ public function getColumnName($item) { $result = htmlentities($item['name']); if (!$this->isMetaboxEmbedded()) { //Build row actions $actions = array(); $actions['edit'] = sprintf('<a href="?page=%s&controller=rules&appaction=edit&id=%s">' . __('Edit', 'psn') . '</a>', $_REQUEST['page'], $item['id']); $actions['delete'] = sprintf('<a href="?page=%s&controller=rules&appaction=delete&id=%s&nonce=%s" class="delConfirm">' . __('Delete', 'psn') . '</a>', $_REQUEST['page'], $item['id'], wp_create_nonce(IfwPsn_Zend_Controller_ModelBinding::getDeleteNonceAction($this->getModelMapper()->getSingular(), $item['id']))); $actionsFilter = IfwPsn_Wp_Proxy_Filter::apply('psn_rules_col_name_actions', array('actions' => $actions, 'item' => $item)); $actions = $actionsFilter['actions']; //Return the title contents $result = sprintf('<b>%1$s</b>%2$s', $item['name'], $this->row_actions($actions)); } return $result; }