if (!defined('DS')) { define('DS', '/'); } // Require the base controller require_once JPATH_COMPONENT . DS . 'controller.php'; jimport('joomla.application.component.model'); require_once JPATH_COMPONENT . DS . 'models' . DS . 'model.php'; // Component Helper jimport('joomla.application.component.helper'); //add Helperpath to JHTML JHTML::addIncludePath(JPATH_COMPONENT . DS . 'helpers'); //include Helper require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'jacc.php'; //set the default view $controller = JRequest::getWord('view', 'jacc'); JaccHelper::addSubmenu($controller); $ControllerConfig = array(); // Require specific controller if requested if ($controller) { $path = JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php'; if (file_exists($path)) { require_once $path; } else { $ControllerConfig = array('viewname' => strtolower($controller), 'mainmodel' => strtolower($controller), 'itemname' => ucfirst(strtolower($controller))); $controller = ''; } } // Create the controller $classname = 'JaccController' . $controller; $controller = new $classname($ControllerConfig); // Perform the Request task
<tr> <td colspan="12"> <?php echo JText::_('There are no items present'); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <input type="hidden" name="option" value="com_jacc" /> <input type="hidden" name="task" value="packages" /> <input type="hidden" name="view" value="packages" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?> " /> <input type="hidden" name="filter_order_Dir" value="" /> <?php echo JHTML::_('form.token'); ?> </form> <div class="clr"></div> <div style="text-align:center;font-weight:bold;padding:10px;">Jacc Version <?php print JaccHelper::getVersion(); ?> </div>
/** * Method to check relations * @access public */ public function checkTables() { $item = $this->getItem(); $lname = strtolower(str_replace('com_', '', $item->name)); $this->_Fields['foreigns'] = array(); foreach ($this->_Tables as $table) { $Name = substr(strrchr($table, '_'), 1); $singular = JaccHelper::getPluralization($Name, 'singular'); $plural = JaccHelper::getPluralization($Name, 'plural'); $fields = $this->_Fields[$table]; $fieldlist = $fields->all; $this->_TablesHas[$table] = new JObject(); foreach ($fieldlist as &$field) { $part = substr($field->get('key'), 0, strpos($field->get('key'), '_')); $pfx = substr(strrchr($field->get('key'), '_'), 1) == 'id'; if ($field->get('key') == 'catid' || $field->get('key') == 'category_id') { $this->_TablesHas[$table]->set('category', $field->get('key')); $primary = $fieldlist['primary']; $this->_extensionXml .= "\n <extension>\n" . " <name>" . $singular . "</name>\n" . " <listview>" . $plural . "</listview>\n" . " <display>" . $fieldlist['hident']->get('key') . "</display>\n" . " <field>" . $field->get('key') . "</field>\n" . " <statefield>" . $fieldlist['state']->get('key') . "</statefield>\n" . " <primary>" . $fieldlist['primary']->get('key') . "</primary>\n" . " <table>" . $table . "</table>\n" . " </extension>\n"; } else { $this->_TablesHas[$table]->set($field->get('key'), $field->get('key')); } if ($part && $pfx && ($foreigntable = $this->_findTable($part))) { $field->set('foreignkey', $part); $field->set('reltable', $foreigntable); $field->set('formfield', $lname . $part); $field->set('size', '1'); $field->set('label', ucfirst($part)); $field->set('fieldtype', $lname . $part); $field->set('required', 'true'); $ffieldslist = $this->_Fields[$foreigntable]; $ffields = $ffieldslist->get('all'); $ffield = $ffields['hident']; $ffieldprim = $ffields['primary']; $this->_Fields['foreigns'][$field->get('key')] = new JObject(); $this->_Fields['foreigns'][$field->get('key')]->set('key', $field->get('key')); $this->_Fields['foreigns'][$field->get('key')]->set('name', $part); $this->_Fields['foreigns'][$field->get('key')]->set('hident', $ffield->get('key')); $this->_Fields['foreigns'][$field->get('key')]->set('primary', $ffieldprim->get('key')); $this->_Fields['foreigns'][$field->get('key')]->set('reltable', $foreigntable); } } } }
/** * This method will replace a lot of placeholders in the given text * @param string $file - a files text content * @param object $item - the component object * @param array $options - some options may be set * @return mixed */ public static function _replace($file, $item, $options = array()) { static $firstname; $date = JFactory::getDate($item->created); $categorytask = $item->params->get('uses_categories') ? JaccHelper::getcategorytask() : ""; $reltable = isset($options['reltable']) ? $options['reltable'] : ''; $extension = isset($options['extension']) ? $options['extension'] : ''; if (empty($firsttable) && isset($options['firstname'])) { $firstname = $options['firstname']; } if (isset($options['submenu']) && trim($options['submenu'])) { $options['submenu'] = "\t\t\t<submenu>\n" . $options['submenu'] . "\n\t\t\t</submenu>"; } $description = $item->description; $version = $item->version; $params = JComponentHelper::getParams('com_jacc'); $com_component = $item->name; $lcomponent = strtolower(str_replace('com_', '', $com_component)); $component = ucfirst($lcomponent); $file = str_replace("##table##", $reltable, $file); $file = str_replace("##extension##", $extension, $file); $file = str_replace("##categorytask##", $categorytask, $file); $file = str_replace("##codestart##", '<?php', $file); $file = str_replace("##codeend##", '?>', $file); $file = str_replace("##Component##", $component, $file); $file = str_replace("##description##", $description, $file); if (isset($options['defaultview']) && $options['defaultview']) { $file = str_replace("##defaultviewname##", $options['defaultview'], $file); } else { $file = str_replace("##defaultviewname##", $firstname, $file); } if (isset($options['plural']) && $options['plural']) { $file = str_replace("##plural##", $options['plural'], $file); $file = str_replace("##Plural##", ucfirst($options['plural']), $file); } $file = str_replace("##firstname##", $firstname, $file); $file = str_replace("##firstnames##", $firstname . 's', $file); $file = str_replace("##version##", $version, $file); $file = str_replace("##table##", $reltable, $file); $file = str_replace("##website##", $params->get('website'), $file); $file = str_replace("##author##", $params->get('author'), $file); $file = str_replace("##sauthor##", $params->get('sauthor'), $file); $file = str_replace("##email##", $params->get('email'), $file); $file = str_replace("##license##", $params->get('license'), $file); $file = str_replace("##component##", $lcomponent, $file); $file = str_replace("##COMPONENT##", strtoupper($lcomponent), $file); $file = str_replace("##date##", $date->format('Y-m-d'), $file); $file = str_replace("##year##", $date->format('Y'), $file); $file = str_replace("##com_component##", $com_component, $file); foreach ($options as $key => $value) { $value = (string) $value; $Ukey = ucfirst($key); $Uvalue = ucfirst($value); $file = str_replace("##" . $key . "##", $value, $file); $file = str_replace("##" . $Ukey . "##", $Uvalue, $file); } //replace category related code, if not needed if (!$item->params->get('uses_categories')) { $pattern = '/##ifdefCategoriesStart##.*##ifdefCategoriesEnd##/isU'; $file = preg_replace($pattern, '', $file); } $pattern = '/\\s+##ifdefCategories.*[Start|End]##+?/isU'; $file = preg_replace($pattern, '', $file); return $file; }
public static function _replace($file, $item, $options = array()) { $date = JFactory::getDate($item->created); $categorytask = $item->params->get('uses_categories') ? JaccHelper::getcategorytask() : ""; $reltable = isset($options['reltable']) ? $options['reltable'] : ''; if (isset($options['submenu']) && trim($options['submenu'])) { $options['submenu'] = "\t\t\t<submenu>\n" . $options['submenu'] . "\n\t\t\t</submenu>"; } $description = $item->description; $version = $item->version; $params = JComponentHelper::getParams('com_jacc'); $com_component = $item->name; $lcomponent = strtolower(str_replace('com_', '', $com_component)); $component = ucfirst($lcomponent); $file = str_replace("##table##", $reltable, $file); $file = str_replace("##categorytask##", $categorytask, $file); $file = str_replace("##codestart##", '<?php', $file); $file = str_replace("##codeend##", '?>', $file); $file = str_replace("##Component##", $component, $file); $file = str_replace("##description##", $description, $file); /** $file = str_replace("##defaultview##", $defaultview, $file); $file = str_replace("##firstname##", $firstName, $file); $file = str_replace("##Firstname##", $UFirstName, $file); **/ $file = str_replace("##version##", $version, $file); $file = str_replace("##table##", $reltable, $file); $file = str_replace("##website##", $params->get('website'), $file); $file = str_replace("##author##", $params->get('author'), $file); $file = str_replace("##sauthor##", $params->get('sauthor'), $file); $file = str_replace("##email##", $params->get('email'), $file); $file = str_replace("##license##", $params->get('license'), $file); $file = str_replace("##component##", $lcomponent, $file); $file = str_replace("##date##", $date->format('Y-m-d'), $file); $file = str_replace("##year##", $date->format('Y'), $file); $file = str_replace("##com_component##", $com_component, $file); foreach ($options as $key => $value) { $value = (string) $value; $Ukey = ucfirst($key); $Uvalue = ucfirst($value); $file = str_replace("##" . $key . "##", $value, $file); $file = str_replace("##" . $Ukey . "##", $Uvalue, $file); } /** $file = str_replace("##name##", $name, $file); $file = str_replace("##Name##", $UName, $file); $file = str_replace("##key##", $key, $file); $file = str_replace("##hident##", $hident, $file); $file = str_replace("##primary##", $primary, $file); $file = str_replace("##menuhelper##", $menuhelper, $file); $file = str_replace("##routerswitch##", $routerswitch, $file); $file = str_replace("##syslanguage##", $syslanguage, $file); **/ return $file; }
/** * 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); } }
/** * * 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; }