コード例 #1
0
 /**
  * Returns the element's full URL.
  *
  * @return string
  */
 public function getUrl()
 {
     if ($this->uri === null) {
         ElementHelper::setUniqueUri($this);
     }
     return parent::getUrl();
 }
コード例 #2
0
 /**
  * Updates an element’s slug and URI, along with any descendants.
  *
  * @param BaseElementModel $element            The element to update.
  * @param bool             $updateOtherLocales Whether the element’s other locales should also be updated.
  * @param bool             $updateDescendants  Whether the element’s descendants should also be updated.
  * @param bool             $asTask             Whether the element’s slug and URI should be updated via a background task.
  *
  * @return null
  */
 public function updateElementSlugAndUri(BaseElementModel $element, $updateOtherLocales = true, $updateDescendants = true, $asTask = false)
 {
     if ($asTask) {
         craft()->tasks->createTask('UpdateElementSlugsAndUris', null, array('elementId' => $element->id, 'elementType' => $element->getElementType(), 'locale' => $element->locale, 'updateOtherLocales' => $updateOtherLocales, 'updateDescendants' => $updateDescendants));
         return;
     }
     ElementHelper::setUniqueUri($element);
     craft()->db->createCommand()->update('elements_i18n', array('slug' => $element->slug, 'uri' => $element->uri), array('elementId' => $element->id, 'locale' => $element->locale));
     // Delete any caches involving this element
     craft()->templateCache->deleteCachesByElement($element);
     if ($updateOtherLocales) {
         $this->updateElementSlugAndUriInOtherLocales($element);
     }
     if ($updateDescendants) {
         $this->updateDescendantSlugsAndUris($element, $updateOtherLocales);
     }
 }
コード例 #3
0
ファイル: ElementsService.php プロジェクト: kant312/sop
 /**
  * Updates an element’s slug and URI, along with any descendants.
  *
  * @param BaseElementModel $element            The element to update.
  * @param bool             $updateOtherLocales Whether the element’s other locales should also be updated.
  * @param bool             $updateDescendants  Whether the element’s descendants should also be updated.
  *
  * @return null
  */
 public function updateElementSlugAndUri(BaseElementModel $element, $updateOtherLocales = true, $updateDescendants = true)
 {
     ElementHelper::setUniqueUri($element);
     craft()->db->createCommand()->update('elements_i18n', array('slug' => $element->slug, 'uri' => $element->uri), array('elementId' => $element->id, 'locale' => $element->locale));
     // Delete any caches involving this element
     craft()->templateCache->deleteCachesByElement($element);
     if ($updateOtherLocales) {
         $this->updateElementSlugAndUriInOtherLocales($element);
     }
     if ($updateDescendants) {
         $this->updateDescendantSlugsAndUris($element);
     }
 }