private function getQueryString() { $request_params = $this->context->getRequest()->getParameterHolder()->getAll(); return ArrayUtil::arrayToQueryString($request_params, array("module", "action")); }
private function doUpdate($dir, $module_name = null) { $input = scandir($dir); foreach ($input as $file) { $tmp = $dir . "/" . $file; if ($file == "." || $file == ".." || $file == ".svn" || substr($file, 0, 1) == ".") { continue; } if ($file != "config" && is_dir($tmp)) { if (!($obj = afWidgetCategoryPeer::getCategoryByModule($file))) { $this->logSection("\n\nFound new module: " . $file . "\n", null); if (!file_exists($tmp . "/config") || !is_dir($tmp . "/config") || !$this->hasXmlFiles(scandir($tmp . "/config"))) { $this->logSection("No widgets found, skipping..", null, null, "COMMENT"); continue; } if ($this->args["all"] == "no" && !$this->askConfirmation("Would you like the module to be processed (y / n)", "QUESTION", "y")) { continue; } $tmp_name = ucwords(sfInflector::humanize($file)); $longname = trim($this->ask("Please provide a name for this module (" . $tmp_name . " by default):", "INFO")); echo "\n\n"; if ($longname == "") { $longname = $tmp_name; } $cat_id = afWidgetCategoryPeer::addNewItem($file, $longname); } else { $longname = $obj->getName(); $cat_id = $obj->getId(); $this->logSection("\n\nFound existing module: " . $file . "\n", null); if (!file_exists($tmp . "/config") || !is_dir($tmp . "/config")) { $this->logSection("No widgets found, skipping..", null, "COMMENT"); continue; } } $this->fixtures["category"]["data"] .= " category" . $cat_id . ":\r\n module: " . $file . "\n name: " . $longname . "\n"; $this->doUpdate($tmp . "/config", $file); } else { if (strtolower(substr($tmp, strrpos($tmp, ".") + 1)) == "xml") { $base = str_replace(".xml", "", $file); $url = $module_name . "/" . $base; $params = null; $permission = $this->isUnAllowedWidget($url); if ($permission == FALSE) { $this->logSection("Found unallowed widget (skipping): ", ucfirst($base), null, "COMMENT"); continue; } else { } if (!($obj = afWidgetSelectorPeer::getWidgetByUrl($url))) { $new = true; $msg = "new"; } else { $new = false; $msg = "existing"; $wid_id = $obj->getId(); $cid = $obj->getCategoryId(); } if (isset($this->pages[$url]) && ($new || !$new && !$obj->getParams())) { $this->logSection("Found " . $msg . " widget, requires params: ", ucfirst($base), null); $item = $this->pages[$url]; $no = 0; foreach ($item["combos"] as $file => $set) { $this->logSection("\n\nOption [" . ($no + 1) . "]", "(page: " . $file . ")", 60, "QUESTION"); foreach ($set as $name => $value) { $this->logSection(null, $name . " = " . $value, null); } $no++; } echo "\n\n"; while (1) { $selected = trim($this->ask("Please choose one of the above configs or hit enter to add custom one:", "QUESTION")); if ($selected === "" || $selected > 0 && $selected <= count($item["combos"])) { if ($selected === "") { $selected = trim($this->ask("Please provide parameters as a query string:", "QUESTION")); } else { $no = 0; foreach ($item["combos"] as $tmp) { if ($no == $selected - 1) { $selected = $tmp; break; } $no++; } } break; } } if (is_array($selected)) { $params = ArrayUtil::arrayToQueryString($selected); } else { $params = $selected; } } if ($new) { $cid = afWidgetCategoryPeer::getCategoryByModule($module_name)->getId(); $wid_id = afWidgetSelectorPeer::addNewItem($url, $cid, $params, $permission); } else { $params = $obj->getParams(); } $this->widgets[] = $wid_id; $this->fixtures["selector"]["data"] .= " widget" . $wid_id . ":\r\n url: " . $url . "\n category_id: category" . $cid . "\n params: " . $params . "\n permission: " . $permission . "\n"; if (!$params) { $this->logSection("Found " . $msg . " widget: ", ucfirst($base), null); } } } $this->count++; } }