Exemple #1
0
 /**
  * Set theme name
  * @param string $name
  */
 public function setName($name)
 {
     if (!empty($name)) {
         $this->name = \tools::sanitizeTechString($name);
     } else {
         throw new \Exception(t('Name can\'t be empty', FALSE));
     }
 }
Exemple #2
0
 /**
  * Set Block ID 
  * @param string $id
  * @return block object
  */
 public function setId($id)
 {
     $id = \tools::sanitizeTechString($id);
     if (!empty($id)) {
         $this->id = $id;
     } else {
         throw new \Exception(t('ID can\'t be empty', FALSE));
     }
     return $this;
 }
Exemple #3
0
 /**
  * Add a theme to the site
  * @param string $thememodule
  * @param string $name
  * @param string $template
  * @param string $patterntype
  * @param string $url
  * @return false 
  */
 protected function addThemeAction($thememodule, $name, $patterntype, $template, $url = '')
 {
     $name = \tools::sanitizeTechString($name);
     if (!is_dir(PROFILE_PATH . $thememodule . '/themes/' . $name)) {
         \tools::createDirectory(PROFILE_PATH . $thememodule . '/themes/' . $name, 0777);
         if ($patterntype === 'template' && !empty($template)) {
             list($oldModule, $oldName) = explode(';', $template);
             $theme = array();
             foreach (\app::$devices as $device) {
                 $theme[$device['name']] = \theme::get($oldModule, $oldName, $device['name']);
                 $theme[$device['name']]->setModule($thememodule);
                 $theme[$device['name']]->setName($name);
                 $theme[$device['name']]->onMove('theme', $thememodule, $name, $device['name'], TRUE);
             }
             if (is_dir('modules/' . $thememodule . '/themes/' . $oldName . '/')) {
                 \tools::copy_dir('modules/' . $thememodule . '/themes/' . $oldName . '/', PROFILE_PATH . $thememodule . '/themes/' . $name . '/');
             } else {
                 \tools::copy_dir(PROFILE_PATH . $thememodule . '/themes/' . $oldName . '/', PROFILE_PATH . $thememodule . '/themes/' . $name . '/');
             }
             foreach (\app::$devices as $device) {
                 $theme[$device['name']]->save();
             }
         } else {
             $theme = new \theme('container', $name, $thememodule);
             $theme->save();
         }
         /* Set theme in preview mode */
         setcookie('THEMEMODULE', $thememodule, time() + 60 * 60 * 24 * 30, '/');
         setcookie('THEME', $name, time() + 60 * 60 * 24 * 30, '/');
         $return = array('eval' => 'top.window.location.reload()', 'notification' => t('The Theme has been created'), 'notificationType' => 'positive');
     } else {
         $return = array('notification' => t('The Theme has not been created, theme already exists'), 'notificationType' => 'negative');
     }
     return $this->returnResult($return);
 }