本文整理汇总了PHP中Alias::getAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Alias::getAlias方法的具体用法?PHP Alias::getAlias怎么用?PHP Alias::getAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alias
的用法示例。
在下文中一共展示了Alias::getAlias方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: issetOrBlank
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
$aliasText = issetOrBlank($_POST['alias']);
$pointer = issetOrBlank($_POST['pointer']);
//echo "Alias: ".$alias.", pointer: ".$pointer;
if ($aliasText != "" && $pointer != "") {
//we can add them if the alias doesn't already exist.
if (!startsWith($aliasText, "/")) {
$aliasText = "/" . $aliasText;
}
$alias = new Alias($conn);
$alias->setAlias($aliasText);
//must start with '/'
$numAliases = sizeof($alias->getObjectsLikeThis());
$alias->setType("url");
$alias->setPointer($pointer);
if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) {
echo '<h1>Alias created OK!</h1>';
echo $alias->getAlias() . " will now point to: " . $pointer;
} else {
if ($numAliases > 0) {
echo '<p>The Alias: ' . $alias->getAlias() . ' already exists</p>';
} else {
if ($alias->getAlias() == "/") {
echo '<p>Alias cannot be saved as /</p>';
//shouldnt occur
} else {
echo '<p>Couldnt save...</p>';
}
}
}
}
示例2: testAlias
public function testAlias()
{
$alias = new Alias('test', 't');
$this->assertEquals('test', $alias->getName());
$this->assertEquals('t', $alias->getAlias());
}
示例3: menubar
menubar();
$aliasText = issetOrBlank($_POST['alias']);
$pointer = issetOrBlank($_POST['pointer']);
if ($aliasText != "" && $pointer != "") {
//we can add them if the alias doesn't already exist.
if (!startsWith($aliasText, "/")) {
$aliasText = "/" . $aliasText;
}
$alias = new Alias($conn);
$alias->setAlias($aliasText);
//must start with '/'
$numAliases = sizeof($alias->getObjectsLikeThis());
if ($numAliases != 0) {
//is this because we only updated the pointer, or because it actually already exists?
//simple check, if the hash with the new aliasText is the same as the old, it's just an update
if ($key == hash('md5', KEY . $alias->getAlias())) {
$numAliases = 0;
}
}
$alias->setPointer($pointer);
$alias->setId($aliasID);
if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) {
echo '<h1>Alias Saved OK!</h1>';
if ($alias->getType() != "url") {
echo $alias->getAlias() . " will point to file ID: " . $pointer;
} else {
echo $alias->getAlias() . " will point to: " . $pointer;
}
} else {
if ($numAliases > 0) {
echo '<p>The Alias: ' . $alias->getAlias() . ' already exists</p>';
示例4: Alias
}
if (issetOrBlank($_POST['file-alias']) != "") {
$alias = new Alias($conn);
$fileAlias = issetOrBlank($_POST['file-alias']);
if (!startsWith($fileAlias, "/")) {
$fileAlias = "/" . $fileAlias;
}
$alias->setAlias($fileAlias);
//must start with '/'
//check if alias already exists first
//pa( $alias->getObjectsLikeThis() );
//echo sizeof( $alias->getObjectsLikeThis() );
$numAliases = sizeof($alias->getObjectsLikeThis());
$alias->setPointer($file->getId());
$alias->setType("file");
if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) {
echo '<h1>Alias created OK!</h1>';
$file->setAliasID($alias->getId());
if ($file->save() > 0) {
echo '<p>File Updated</p>';
}
} else {
if ($numAliases > 0) {
echo '<p>The Alias: ' . $alias->getAlias() . ' already exists</p>';
} else {
if ($alias->getAlias() == "/") {
echo '<p>Alias cannot be saved as /</p>';
//shouldnt occur
} else {
echo '<p>Couldnt save...</p>';
}
示例5: _cleanData
/**
* Clean data method
*
* @param array $data
* @return array $data
*/
protected function _cleanData($data)
{
// handle if we are saving a page automatically and only have the alias
if (!empty($data['Alias']['name']) && empty($data['WebpageMenuItem']['item_url'])) {
$data['WebpageMenuItem']['item_url'] = '/' . $data['Alias']['name'];
}
// handle beforeSave() type data
if (empty($data['WebpageMenuItem']['parent_id']) && !empty($data['WebpageMenuItem']['menu_id'])) {
$data['WebpageMenuItem']['parent_id'] = $data['WebpageMenuItem']['menu_id'];
}
// handle save() type data
if (empty($data['parent_id']) && !empty($data['menu_id'])) {
$data['parent_id'] = $data['menu_id'];
}
// handle beforeSave() type data
if (empty($data['WebpageMenuItem']['name']) && !empty($data['WebpageMenuItem']['item_text'])) {
$data['WebpageMenuItem']['name'] = $data['WebpageMenuItem']['item_text'];
}
// handle save() type data
if (empty($data['name']) && !empty($data['item_text'])) {
$data['name'] = $data['item_text'];
}
// put data in, to create a check data for whether to create page or not()
// it is in the cleanData function because we add some data to the save depending on creation of a page
// make sure this gets fired last after all other $data updates
if (!empty($data['WebpageMenuItem']['item_url']) && strpos($data['WebpageMenuItem']['item_url'], 'http') !== 0) {
// if link_url starts with http do nothing
} elseif ($data['WebpageMenuItem']['page_type'] == 'content' || $data['WebpageMenuItem']['page_type'] == 'section' || $data['WebpageMenuItem']['page_type'] == 'plugin') {
// NOTE : don't change this if above, if you do installing a new site fails
App::uses('Alias', 'Model');
$Alias = new Alias();
// else see if the page already exists
$url = strpos($data['WebpageMenuItem']['item_url'], '/') === 0 ? substr($data['WebpageMenuItem']['item_url'], 1) : $data['WebpageMenuItem']['item_url'];
$urlAlias = $Alias->getAlias($url);
$textAlias = $Alias->getAlias($data['WebpageMenuItem']['item_text']);
if (!empty($urlAlias['old']) || !empty($textAlias['old'])) {
// if it does we don't need create a page, just move on ignoring the rest
$data['WebpageMenuItem']['item_url'] = !empty($data['WebpageMenuItem']['item_url']) ? $data['WebpageMenuItem']['item_url'] : '/' . $textAlias['old'];
} elseif ($data['WebpageMenuItem']['page_type'] == 'content' || $data['WebpageMenuItem']['page_type'] == 'section') {
// if not then create page (depending on page type)
$this->set($data);
if ($this->validates()) {
// map menu data to webpage data
$webpage['Alias']['name'] = empty($data['WebpageMenuItem']['item_url']) ? $Alias->getNewAlias($data['WebpageMenuItem']['item_text']) : null;
// if link_url is blank, set the link_url from the name (asciifyy)
$webpage['Webpage']['name'] = $data['WebpageMenuItem']['item_text'];
$webpage['Webpage']['title'] = $data['WebpageMenuItem']['item_text'];
App::uses('Webpage', 'Webpages.Model');
$Webpage = new Webpage();
$webpage = $Webpage->placeholder($webpage, array('create' => true, 'type' => $data['WebpageMenuItem']['page_type']));
unset($webpage['Webpage']);
// don't want returned data to save again
unset($webpage['Child']);
// don't want returned data to save again
unset($webpage['Alias']);
// don't want returned data to save again
$data = Set::merge($data, $webpage);
} else {
// it isn't going to save anyway, it didn't validate so do nothing, data should be resubmitted
}
} elseif ($data['WebpageMenuItem']['page_type'] == 'plugin') {
$plugin = ZuhaInflector::pluginize($data['WebpageMenuItem']['item_text']);
App::uses($plugin . 'AppModel', $plugin . '.Model');
$className = $plugin . 'AppModel';
$Model = new $className();
if (method_exists($Model, 'menuInit')) {
// see if the plugin model has a function to generate starting links (note : handle test data in the schema)
$data = $Model->menuInit($data);
} else {
throw new Exception('Create the menuInit() method in the ' . $plugin . 'AppModel file.');
}
}
}
if (!empty($data['WebpageMenuItem']['parent_id']) && empty($data['WebpageMenuItem']['user_role_id'])) {
$data['WebpageMenuItem']['user_role_id'] = $this->field('user_role_id', array($this->alias . '.id' => $data['WebpageMenuItem']['parent_id']));
}
if (!empty($data['ChildMenuItem'][0])) {
for ($i = 0; $i < count($data['ChildMenuItem']); ++$i) {
if (empty($data['ChildMenuItem'][$i]['user_role_id']) && !empty($data['WebpageMenuItem']['user_role_id'])) {
$data['ChildMenuItem'][$i]['user_role_id'] = $data['WebpageMenuItem']['user_role_id'];
}
}
}
return $data;
}
示例6: parseAlias
function parseAlias($intAliasId, $strCommand)
{
global $_PATHS, $_CLEAN_POST, $_CONF, $objLang, $objLiveUser;
$objTpl = new HTML_Template_IT($_PATHS['templates']);
$objTpl->loadTemplatefile("alias.tpl.htm");
$blnError = false;
switch ($strCommand) {
case CMD_LIST:
case CMD_ADD:
case CMD_EDIT:
//*** Post the profile form if submitted.
if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editAlias") {
//*** The element form has been posted.
//*** Check sanitized input.
if (is_null($_CLEAN_POST["frm_active"])) {
$blnError = true;
}
if (is_null($_CLEAN_POST["frm_alias"])) {
$blnError = true;
}
if (is_null($_CLEAN_POST["frm_language"])) {
$blnError = true;
}
if (is_null($_CLEAN_POST["frm_element"])) {
$blnError = true;
}
if (is_null($_CLEAN_POST["dispatch"])) {
$blnError = true;
}
if ($blnError === true) {
//*** Display global error.
$objTpl->setVariable("FORM_ACTIVE_VALUE", $_POST["frm_active"] == "on" ? "checked=\"checked\"" : "");
$objTpl->setVariable("FORM_ALIAS_VALUE", $_POST["frm_alias"]);
$objTpl->setVariable("ERROR_ALIAS_MAIN", $objLang->get("main", "formerror"));
} else {
//*** Input is valid. Save the alias.
if ($strCommand == CMD_EDIT) {
$objAlias = Alias::selectByPK($intAliasId);
} else {
$objAlias = new Alias();
}
$objAlias->setAccountId($_CONF['app']['account']->getId());
$objAlias->setActive($_POST["frm_active"] == "on" ? 1 : 0);
$objAlias->setLanguageId(empty($_CLEAN_POST["frm_language"]) ? 0 : $_CLEAN_POST["frm_language"]);
$objAlias->setAlias($_CLEAN_POST["frm_alias"]);
$objAlias->setUrl($_CLEAN_POST["frm_element"]);
$objAlias->save();
header("Location: " . Request::getURI() . "/?cid=" . NAV_PCMS_ALIASES);
exit;
}
}
//*** Initiate child element loop.
$objAliases = Alias::selectSorted();
$totalCount = 0;
$listCount = 0;
$intPosition = request("pos");
$intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0;
$intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"];
//*** Find total count.
foreach ($objAliases as $objAlias) {
$strAlias = $objAlias->getAlias();
if (!empty($strAlias)) {
$totalCount++;
}
}
$objAliases->seek($intPosition);
$objLanguages = ContentLanguage::select();
foreach ($objAliases as $objAlias) {
$strAlias = $objAlias->getAlias();
if (!empty($strAlias)) {
$strUrl = $objAlias->getUrl();
if (is_numeric($strUrl)) {
$objElement = Element::selectByPk($strUrl);
if (is_object($objElement)) {
$strUrlHref = "?eid={$strUrl}&cmd=" . CMD_EDIT . "&cid=" . NAV_PCMS_ELEMENTS;
$strUrl = Element::recursivePath($strUrl);
} else {
$strUrlHref = "?cid=" . NAV_PCMS_ALIASES;
$strUrl = "<b>" . $objLang->get("aliasUnavailable", "label") . "</b>";
}
}
$objTpl->setCurrentBlock("multiview-item");
$objTpl->setVariable("MULTIITEM_VALUE", $objAlias->getId());
$objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Alias.remove({$objAlias->getId()});");
$objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
$objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_ALIASES . "&eid={$objAlias->getId()}&cmd=" . CMD_EDIT);
$objTpl->setVariable("MULTIITEM_TYPE_CLASS", "alias");
$objTpl->setVariable("MULTIITEM_ALIAS", $objAlias->getAlias());
$objTpl->setVariable("MULTIITEM_POINTS_TO", $objLang->get("pointsTo", "label"));
$objTpl->setVariable("MULTIITEM_URL", $strUrl);
$objTpl->setVariable("MULTIITEM_URL_HREF", $strUrlHref);
if ($objLanguages->count() > 1) {
if ($objAlias->getLanguageId() > 0) {
$strLanguage = ContentLanguage::selectByPK($objAlias->getLanguageId())->getName();
$objTpl->setVariable("MULTIITEM_LANGUAGE", sprintf($objLang->get("forLanguage", "label"), $strLanguage));
} else {
$objTpl->setVariable("MULTIITEM_LANGUAGE", $objLang->get("forAllLanguages", "label"));
}
} else {
$objTpl->setVariable("MULTIITEM_LANGUAGE", "");
//.........这里部分代码省略.........