示例#1
0
文件: Menu.php 项目: piwik/piwik
 private function getFirstTypeIfOnlyOneIsInUse()
 {
     $types = $this->typeManager->getAllTypes();
     if (count($types) === 1) {
         // only one type is in use, use this one for the wording
         return reset($types);
     } else {
         // multiple types are activated, check whether only one is actually in use
         $model = new Model();
         $typeIds = $model->getUsedTypeIds();
         if (count($typeIds) === 1) {
             $typeManager = new TypeManager();
             return $typeManager->getType(reset($typeIds));
         }
     }
 }
 public function save()
 {
     Piwik::checkUserHasAdminAccess($this->idSite);
     $typeManager = new TypeManager();
     $type = $typeManager->getType($this->idType);
     /**
      * Triggered just before Measurable settings are about to be saved. You can use this event for example
      * to validate not only one setting but multiple ssetting. For example whether username
      * and password matches.
      *
      * @since Piwik 2.14.0
      * @deprecated will be removed in Piwik 3.0.0
      *
      * @param MeasurableSettings $this
      * @param \Piwik\Measurable\Type $type
      * @param int $idSite
      */
     Piwik::postEvent('Measurable.beforeSaveSettings', array($this, $type, $this->idSite));
     $this->storage->save();
 }
示例#3
0
文件: API.php 项目: mgou-net/piwik
 /**
  * Returns all available measurable types.
  * Marked as deprecated so it won't appear in API page. It won't be a public API for now.
  * @deprecated
  * @return array
  */
 public function getAvailableMeasurableTypes()
 {
     Piwik::checkUserHasSomeViewAccess();
     $typeManager = new TypeManager();
     $types = $typeManager->getAllTypes();
     $available = array();
     foreach ($types as $type) {
         $available[] = array('id' => $type->getId(), 'name' => Piwik::translate($type->getName()), 'description' => Piwik::translate($type->getDescription()), 'howToSetupUrl' => $type->getHowToSetupUrl());
     }
     return $available;
 }
示例#4
0
文件: API.php 项目: piwik/piwik
 /**
  * Returns all available measurable types.
  * Marked as deprecated so it won't appear in API page. It won't be a public API for now.
  * @deprecated
  * @return array
  */
 public function getAvailableMeasurableTypes()
 {
     Piwik::checkUserHasSomeViewAccess();
     $typeManager = new TypeManager();
     $types = $typeManager->getAllTypes();
     $available = array();
     foreach ($types as $type) {
         $measurableSettings = $this->settingsProvider->getAllMeasurableSettings($idSite = 0, $type->getId());
         $settingsMetadata = new SettingsMetadata();
         $available[] = array('id' => $type->getId(), 'name' => Piwik::translate($type->getName()), 'description' => Piwik::translate($type->getDescription()), 'howToSetupUrl' => $type->getHowToSetupUrl(), 'settings' => $settingsMetadata->formatSettings($measurableSettings));
     }
     return $available;
 }