本文整理汇总了PHP中Redirect::setValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Redirect::setValues方法的具体用法?PHP Redirect::setValues怎么用?PHP Redirect::setValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redirect
的用法示例。
在下文中一共展示了Redirect::setValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirectsAction
public function redirectsAction()
{
if ($this->_getParam("data")) {
if ($this->getUser()->isAllowed("redirects")) {
if ($this->_getParam("xaction") == "destroy") {
$id = Zend_Json::decode($this->_getParam("data"));
$redirect = Redirect::getById($id);
$redirect->delete();
$this->_helper->json(array("success" => true, "data" => array()));
} else {
if ($this->_getParam("xaction") == "update") {
$data = Zend_Json::decode($this->_getParam("data"));
// save redirect
$redirect = Redirect::getById($data["id"]);
if ($data["target"]) {
if ($doc = Document::getByPath($data["target"])) {
$data["target"] = $doc->getId();
}
}
$redirect->setValues($data);
$redirect->save();
$redirectTarget = $redirect->getTarget();
if (is_numeric($redirectTarget)) {
if ($doc = Document::getById(intval($redirectTarget))) {
$redirect->setTarget($doc->getFullPath());
}
}
$this->_helper->json(array("data" => $redirect, "success" => true));
} else {
if ($this->_getParam("xaction") == "create") {
$data = Zend_Json::decode($this->_getParam("data"));
unset($data["id"]);
// save route
$redirect = new Redirect();
if ($data["target"]) {
if ($doc = Document::getByPath($data["target"])) {
$data["target"] = $doc->getId();
}
}
$redirect->setValues($data);
$redirect->save();
$redirectTarget = $redirect->getTarget();
if (is_numeric($redirectTarget)) {
if ($doc = Document::getById(intval($redirectTarget))) {
$redirect->setTarget($doc->getFullPath());
}
}
$this->_helper->json(array("data" => $redirect, "success" => true));
}
}
}
} else {
Logger::err("user [" . $this->getUser()->getId() . "] attempted to modify static routes, but has no permission to do so.");
}
} else {
// get list of routes
$list = new Redirect_List();
$list->setLimit($this->_getParam("limit"));
$list->setOffset($this->_getParam("start"));
if ($this->_getParam("sort")) {
$list->setOrderKey($this->_getParam("sort"));
$list->setOrder($this->_getParam("dir"));
}
if ($this->_getParam("filter")) {
$list->setCondition("`source` LIKE " . $list->quote("%" . $this->_getParam("filter") . "%") . " OR `target` LIKE " . $list->quote("%" . $this->_getParam("filter") . "%"));
}
$list->load();
$redirects = array();
foreach ($list->getRedirects() as $redirect) {
if ($link = $redirect->getTarget()) {
if (is_numeric($link)) {
if ($doc = Document::getById(intval($link))) {
$redirect->setTarget($doc->getFullPath());
}
}
}
$redirects[] = $redirect;
}
$this->_helper->json(array("data" => $redirects, "success" => true, "total" => $list->getTotalCount()));
}
$this->_helper->json(false);
}
示例2: install
/**
* install function
* @return string $message statusmessage to display in frontend
*/
public static function install()
{
$translate = new Zend_Translate('csv', PIMCORE_PLUGINS_PATH . self::getTranslationFile('en'), 'en', array('delimiter' => ','));
$message = "";
//create folder for search in website
mkdir(PIMCORE_WEBSITE_PATH . "/var/search", 0755, true);
//set up search config
$searchConf = '<?xml version="1.0"?>
<zend-config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
<search>
<frontend>
<index>website/var/search/frontend/index/</index>
<ignoreLanguage>1</ignoreLanguage>
<fuzzySearch>1</fuzzySearch>
<enabled>0</enabled>
<urls></urls>
<validLinkRegexes></validLinkRegexes>
<invalidLinkRegexesEditable></invalidLinkRegexesEditable>
<invalidLinkRegexes>@.*\\.(js|JS|gif|GIF|jpg|JPG|png|PNG|ico|ICO|eps|jpeg|JPEG|bmp|BMP|css|CSS|sit|wmf|zip|ppt|mpg|xls|gz|rpm|tgz|mov|MOV|exe|mp3|MP3|kmz|gpx|kml|swf|SWF)$@</invalidLinkRegexes>
<categories></categories>
<crawler>
<maxThreads>20</maxThreads>
<maxLinkDepth>15</maxLinkDepth>
<contentStartIndicator></contentStartIndicator>
<contentEndIndicator></contentEndIndicator>
<forceStart>0</forceStart>
<running>0</running>
<started></started>
<finished></finished>
<forceStop>0</forceStop>
<forceStopInitiated></forceStopInitiated>
</crawler>
<ownHostOnly>0</ownHostOnly>
</frontend>
</search>
</zend-config>';
file_put_contents(PIMCORE_WEBSITE_PATH . "/var/search/search.xml", $searchConf);
if (file_exists(PIMCORE_WEBSITE_PATH . "/var/search/search.xml")) {
$searchConf = new Zend_Config_Xml(PIMCORE_WEBSITE_PATH . "/var/search/search.xml");
if ($searchConf->search->frontend->enabled) {
self::forceCrawlerStartOnNextMaintenance("frontend");
}
$index = PIMCORE_DOCUMENT_ROOT . "/" . $searchConf->search->frontend->index;
//create frontend search index dir
if (!empty($index) and !is_dir($index)) {
$success = mkdir($index, 0755, true);
chmod($index, 0755);
if ($success) {
$message .= $translate->_("created_frontend_index_dir");
} else {
$message .= $translate->_("could_not_create_frontend_index_dir");
}
} else {
$message .= $translate->_("frontend_index_dir_not_configured");
}
} else {
$message .= $translate->_("failed_to_setup_search_config");
}
//add redirect for sitemap.xml
$redirect = new Redirect();
$redirect->setValues(array("source" => "/\\/sitemap.xml/", "target" => "/plugin/SearchPhp/frontend/sitemap", "statusCode" => 301, "priority" => 10));
$redirect->save();
return $message;
}