Пример #1
0
 /**
  * Get data hook locations
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _getDataLocationsForAdd()
 {
     $i = intval($this->request['i']);
     $_locations = IPSLib::getDataHookLocations();
     $output = $this->registry->output->formDropdown("dataLocation[{$i}]", $_locations);
     $this->returnHtml($output);
 }
Пример #2
0
 /**
  * Hook add/edit form
  * This dynamic form allows users to associate multiple files with a single hook.
  *
  * @param	string		[add|edit]
  * @return	@e void		[Outputs to screen]
  */
 protected function _hookForm($type = 'add')
 {
     /* Init vars */
     $form = array();
     $files = array();
     $hookData = array();
     $requirements = array();
     $entryPoints = array('foreach' => array(array('outer.pre', $this->lang->words['h_outerpre']), array('inner.pre', $this->lang->words['h_innerpre']), array('inner.post', $this->lang->words['h_innerpost']), array('outer.post', $this->lang->words['h_outerpost'])), 'if' => array(array('pre.startif', $this->lang->words['h_prestartif']), array('post.startif', $this->lang->words['h_poststartif']), array('pre.else', $this->lang->words['h_preelse']), array('post.else', $this->lang->words['h_postelse']), array('pre.endif', $this->lang->words['h_preendif']), array('post.endif', $this->lang->words['h_postendif'])));
     /* Edit time? */
     if ($type == 'edit') {
         $id = intval($this->request['id']);
         if (!$id) {
             $this->registry->output->showError($this->lang->words['h_noedit'], 1116);
         }
         $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id));
         if (!$hookData['hook_id']) {
             $this->registry->output->showError($this->lang->words['h_noedit'], 1117);
         }
         /* Sort out extra stuff and requirements */
         $hookData['hook_extra_data'] = unserialize($hookData['hook_extra_data']);
         $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
         /* Old data? - @todo: we should remove that around 3.3(4?) */
         if (!isset($hookData['hook_requirements']['required_applications']['core']) && isset($hookData['hook_requirements']['hook_ipb_version_min']) && ($hookData['hook_requirements']['hook_ipb_version_min'] > 0 || $hookData['hook_requirements']['hook_ipb_version_max'] > 0)) {
             $requirements['core'] = array('min_version' => intval($hookData['hook_requirements']['hook_ipb_version_min']), 'max_version' => intval($hookData['hook_requirements']['hook_ipb_version_max']));
         }
         if (is_array($hookData['hook_requirements']['required_applications']) && count($hookData['hook_requirements']['required_applications'])) {
             /* Get the setup class */
             require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
             /*noLibHook*/
             foreach ($hookData['hook_requirements']['required_applications'] as $appKey => $versionData) {
                 /* Fetch and check versions */
                 if (!isset($this->cachedVersions[$appKey])) {
                     $this->cachedVersions[$appKey] = IPSSetUp::fetchXmlAppVersions($appKey);
                 }
                 $_versions = $this->cachedVersions[$appKey];
                 krsort($_versions);
                 /* Setup our default 'no version' value */
                 $versions = array(array(0, $this->lang->words['h_any_version']));
                 foreach ($_versions as $long => $human) {
                     if ($long < 30000 && in_array($appKey, array('core', 'forums', 'members'))) {
                         continue;
                     }
                     $versions[] = array($long, $human);
                 }
                 $versionData['_versions'] = $versions;
                 $requirements[$appKey] = $versionData;
             }
         }
         /* Sort out hook files */
         $index = 1;
         $skinGroups = $this->hooksFunctions->getSkinGroups();
         $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id));
         $outer = $this->DB->execute();
         /* Get them outside the while cycle to prevent warnings */
         $_dataHooks = IPSLib::getDataHookLocations();
         while ($r = $this->DB->fetch($outer)) {
             $r['hook_data'] = unserialize($r['hook_data']);
             if ($r['hook_type'] == 'templateHooks') {
                 $templates = $this->hooksFunctions->getSkinMethods($r['hook_data']['skinGroup']);
                 $hookIds = $this->hooksFunctions->getHookIds($r['hook_data']['skinFunction'], $r['hook_data']['type']);
                 $r['_skinDropdown'] = $this->registry->output->formDropdown("skinGroup[{$index}]", $skinGroups, $r['hook_data']['skinGroup'], "skinGroup[{$index}]", "onchange='getTemplatesForAdd({$index});'");
                 $r['_templateDropdown'] = $this->registry->output->formDropdown("skinFunction[{$index}]", $templates, $r['hook_data']['skinFunction'], "skinFunction[{$index}]", "onchange='getTypeOfHook({$index});'");
                 $r['_hookTypeDropdown'] = $this->registry->output->formDropdown("type[{$index}]", array(array(0, $this->lang->words['a_selectone']), array('foreach', $this->lang->words['hook_foreach_loop']), array('if', $this->lang->words['hook_if_statement'])), $r['hook_data']['type'], "type[{$index}]", "onchange='getHookIds({$index});'");
                 $r['_hookIdsDropdown'] = $this->registry->output->formDropdown("id[{$index}]", $hookIds, $r['hook_data']['id'], "id[{$index}]", "onchange='getHookEntryPoints({$index});'");
                 $r['_hookEPDropdown'] = $this->registry->output->formDropdown("position[{$index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'], $r['hook_data']['position']);
             }
             if ($r['hook_type'] == 'dataHooks') {
                 $r['_dataLocationDropdown'] = $this->registry->output->formDropdown("dataLocation[{$index}]", $_dataHooks, $r['hook_data']['dataLocation']);
             }
             $files[$index] = $r;
             $index++;
         }
         $action = 'do_edit_hook';
     } else {
         $action = 'do_create_hook';
     }
     /* Info */
     foreach (array('hook_name', 'hook_desc', 'hook_key', 'hook_version_human', 'hook_version_long', 'hook_author', 'hook_email', 'hook_website', 'hook_update_check') as $_hook_key) {
         $form[$_hook_key] = $this->registry->output->formSimpleInput($_hook_key, isset($this->request[$_hook_key]) ? $this->request[$_hook_key] : $hookData[$_hook_key], 60);
     }
     /* Requirements */
     foreach (array('hook_php_version_min', 'hook_php_version_max') as $_version_key) {
         $form[$_version_key] = $this->registry->output->formSimpleInput($_version_key, isset($this->request[$_version_key]) ? $this->request[$_version_key] : $hookData['hook_requirements'][$_version_key], 20);
     }
     /* Setup the global caches DD */
     $_caches = array();
     $this->DB->build(array('select' => 'cs_key', 'from' => 'cache_store', 'order' => 'cs_key ASC'));
     $this->DB->execute();
     while ($gc = $this->DB->fetch()) {
         $_caches[] = array($gc['cs_key'], $gc['cs_key']);
     }
     sort($_caches);
     $form['hook_global_caches'] = $this->registry->output->formMultiDropdown('hook_global_caches[]', $_caches, isset($_POST['hook_global_caches']) ? $_POST['hook_global_caches'] : explode(',', $hookData['hook_global_caches']), 15);
     /* Get some data for the javascript */
     $form['jsDataTypes'] = IPSText::br2nl($this->registry->output->formDropdown("type[#{index}]", array(array(0, $this->lang->words['a_selectone']), array('foreach', $this->lang->words['hook_foreach_loop']), array('if', $this->lang->words['hook_if_statement'])), '', "type[#{index}]", "onchange='getHookIds(#{index});'"));
     $form['jsDataPoints'] = IPSText::br2nl($this->registry->output->formDropdown("position[#{index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if']));
     /* Output */
     $this->registry->output->extra_nav[] = array($this->settings['base_url'] . $this->form_code . 'do=hooks_overview', $this->lang->words['menu__manage_hooks']);
     $this->registry->output->html .= $this->html->hookForm($form, $action, $hookData, $files, $requirements);
 }