本文整理汇总了PHP中Redirect::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Redirect::save方法的具体用法?PHP Redirect::save怎么用?PHP Redirect::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redirect
的用法示例。
在下文中一共展示了Redirect::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLunacinema
public function actionLunacinema($clientId = null, $goto = null)
{
$redirect = new Redirect();
$redirect->clientId = $clientId ?: 0;
$redirect->redirected = $goto ?: 'index';
$redirect->url = Yii::app()->getRequest()->getRequestUri();
$redirect->comment = 'redirect for luna cinema';
$redirect->save();
$this->redirect($goto ?: $this->createUrl('site/index'));
}
示例2: update
/**
*
*/
public function update()
{
parent::update();
$config = Pimcore_Config::getSystemConfig();
if ($this->_oldPath && $config->documents->createredirectwhenmoved) {
// create redirect for old path
$redirect = new Redirect();
$redirect->setTarget($this->getId());
$redirect->setSource("@" . $this->_oldPath . "/?@");
$redirect->setStatusCode(301);
$redirect->setExpiry(time() + 86400 * 60);
// this entry is removed automatically after 60 days
$redirect->save();
}
}
示例3: 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);
}
示例4: saveAction
public function saveAction()
{
if ($this->_getParam("id")) {
$page = Document_Page::getById($this->_getParam("id"));
$page = $this->getLatestVersion($page);
$page->setUserModification($this->getUser()->getId());
// save to session
$key = "document_" . $this->_getParam("id");
$session = new Zend_Session_Namespace("pimcore_documents");
$session->{$key} = $page;
if ($this->_getParam("task") == "unpublish") {
$page->setPublished(false);
}
if ($this->_getParam("task") == "publish") {
$page->setPublished(true);
}
// check for redirects
if ($this->getUser()->isAllowed("redirects") && $this->_getParam("settings")) {
$settings = Zend_Json::decode($this->_getParam("settings"));
if (is_array($settings)) {
$redirectList = new Redirect_List();
$redirectList->setCondition("target = ?", $page->getId());
$existingRedirects = $redirectList->load();
$existingRedirectIds = array();
foreach ($existingRedirects as $existingRedirect) {
$existingRedirectIds[$existingRedirect->getId()] = $existingRedirect->getId();
}
for ($i = 1; $i < 100; $i++) {
if (array_key_exists("redirect_url_" . $i, $settings)) {
// check for existing
if ($settings["redirect_id_" . $i]) {
$redirect = Redirect::getById($settings["redirect_id_" . $i]);
unset($existingRedirectIds[$redirect->getId()]);
} else {
// create new one
$redirect = new Redirect();
}
$redirect->setSource($settings["redirect_url_" . $i]);
$redirect->setTarget($page->getId());
$redirect->setStatusCode(301);
$redirect->save();
}
}
// remove existing redirects which were delete
foreach ($existingRedirectIds as $existingRedirectId) {
$redirect = Redirect::getById($existingRedirectId);
$redirect->delete();
}
}
}
// only save when publish or unpublish
if ($this->_getParam("task") == "publish" && $page->isAllowed("publish") or $this->_getParam("task") == "unpublish" && $page->isAllowed("unpublish")) {
$this->setValuesToDocument($page);
try {
$page->save();
$this->_helper->json(array("success" => true));
} catch (Exception $e) {
Logger::err($e);
$this->_helper->json(array("success" => false, "message" => $e->getMessage()));
}
} else {
if ($page->isAllowed("save")) {
$this->setValuesToDocument($page);
try {
$page->saveVersion();
$this->_helper->json(array("success" => true));
} catch (Exception $e) {
Logger::err($e);
$this->_helper->json(array("success" => false, "message" => $e->getMessage()));
}
}
}
}
$this->_helper->json(false);
}
示例5: 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;
}