Esempio n. 1
0
 /**
  * Method to rename placeholders of filenames
  * @param hash options  
  */
 public function customizeFiles($options)
 {
     $files = $this->getTempFiles();
     $item = $this->getItem();
     for ($i = 0; $i < count($files); $i++) {
         $renamings = $this->getRenaming();
         if (count($renamings)) {
             foreach ($renamings as $replace => $pattern) {
                 //rename files
                 if (stripos($files[$i], $pattern)) {
                     $newfile = str_replace($pattern, $replace, $files[$i]);
                     JFile::move($files[$i], $newfile);
                     $files[$i] = $newfile;
                 }
             }
         }
         //replace the patterns
         $data = file_get_contents($files[$i]);
         $data = JaccHelper::_replace($data, $item, $options);
         file_put_contents($files[$i], $data);
     }
 }
Esempio n. 2
0
 /**
  * 
  * Enter description here ...
  * @param unknown_type $item
  * @param unknown_type $options
  */
 function copyCVPair($options)
 {
     jimport('joomla.filesystem.folder');
     $model = $this->getModel($this->_mainmodel);
     $item = $model->getItem();
     if (!trim($options['name'])) {
         return;
     }
     $name = JFilterOutput::stringURLSafe($options['name']);
     $admin = array();
     $site = array();
     if ($options['option'] == 'backend' || $options['option'] == 'both') {
         if (!JFolder::exists($model->getTempPath(true) . 'admin' . DS . 'views' . DS . $name)) {
             JFolder::copy(JPATH_COMPONENT . DS . 'templates' . DS . 'vcpair' . DS . 'admin' . DS . '#name#', $model->getTempPath(true) . 'admin' . DS . 'views' . DS . $name, '', true);
             $admin = JFolder::files($model->getTempPath(true) . 'admin' . DS . 'views' . DS . $name, '.', true, true);
         }
         if (!JFile::exists($model->getTempPath(true) . 'admin' . DS . 'controllers' . DS . $name . '.php')) {
             JFile::copy(JPATH_COMPONENT . DS . 'templates' . DS . 'vcpair' . DS . 'admin' . DS . '#name#.php', $model->getTempPath(true) . 'admin' . DS . 'controllers' . DS . $name . '.php');
         }
     }
     if ($options['option'] == 'frontend' || $options['option'] == 'both') {
         if (!JFolder::exists($model->getTempPath(true) . 'site' . DS . 'views' . DS . $name)) {
             JFolder::copy(JPATH_COMPONENT . DS . 'templates' . DS . 'vcpair' . DS . 'site' . DS . '#name#', $model->getTempPath(true) . 'site' . DS . 'views' . DS . $name, '', true);
             $site = JFolder::files($model->getTempPath(true) . 'site' . DS . 'views' . DS . $name, '.', true, true);
         }
         if (!JFile::exists($model->getTempPath(true) . 'site' . DS . 'controllers' . DS . $name . '.php')) {
             JFile::copy(JPATH_COMPONENT . DS . 'templates' . DS . 'vcpair' . DS . 'site' . DS . '#name#.php', $model->getTempPath(true) . 'site' . DS . 'controllers' . DS . $name . '.php');
         }
     }
     $files = array_merge($admin, $site);
     if ($options['option'] == 'frontend' || $options['option'] == 'both') {
         $files[] = $model->getTempPath(true) . 'site' . DS . 'controllers' . DS . $name . '.php';
     }
     if ($options['option'] == 'backend' || $options['option'] == 'both') {
         $files[] = $model->getTempPath(true) . 'admin' . DS . 'controllers' . DS . $name . '.php';
     }
     for ($i = 0; $i < count($files); $i++) {
         $data = file_get_contents($files[$i]);
         $data = JaccHelper::_replace($data, $item, array('name' => $name));
         file_put_contents($files[$i], $data);
     }
     return $files;
 }