/** * Prepare form * * @param Uni_Core_Form $form */ protected function _prepareForm(Uni_Core_Form $form) { $form->setName('menu')->setMethod('post'); $subForm1 = new Zend_Form_SubForm(); $subForm1->setLegend('Menu Item Information'); $subForm1->setDescription('Menu Item Information'); $idField = new Zend_Form_Element_Hidden('id'); $title = new Zend_Form_Element_Text('title', array('class' => 'required', 'maxlength' => 200)); $title->setRequired(true)->setLabel('Title')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $link = new Zend_Form_Element_Text('link', array('maxlength' => 200)); $link->setLabel('Link')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setDescription('Use module/controller/action for internal links or http://www.example.com for external links'); $open_window = new Zend_Form_Element_Select('open_window', array('class' => 'required', 'maxlength' => 200)); $open_window->setRequired(true)->setLabel('Open Window')->setMultiOptions(Fox::getModel('navigation/menu')->getAllTargetWindows()); $status = new Zend_Form_Element_Select('status', array('class' => 'required', 'maxlength' => 200)); $status->setRequired(true)->setLabel('Status')->setMultiOptions(Fox::getModel('navigation/menu')->getAllStatuses()); $sort_order = new Zend_Form_Element_Text('sort_order', array('class' => 'required', 'maxlength' => 200)); $sort_order->setRequired(true)->setLabel('Sort Order')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $style_class = new Zend_Form_Element_Text('style_class'); $style_class->setLabel('Style Class')->addFilter('StripTags')->addFilter('StringTrim'); $menugroup = new Zend_Form_Element_Multiselect('menu_group', array('class' => 'required')); $menugroup->setRequired(true)->setLabel('Menu Group')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->setMultiOptions(Fox::getModel('navigation/menugroup')->getMenuGroupOptions()); $subForm1->addElements(array($idField, $title, $link, $open_window, $sort_order, $style_class, $status, $menugroup)); $form->addSubForm($subForm1, 'subform1'); parent::_prepareForm($form); }
/** * Get config * * @return Fox_Extensionmanager_Model_Config */ protected function getConfig() { if (!$this->config) { $this->config = Fox::getModel("extensionmanager/config"); } return $this->config; }
/** * Get all generated packages * * @return array */ public function getAllGeneratedPackages() { $package = Fox::getModel("extensionmanager/generate/package"); $pkgPath = $package->getGeneratedPkgDir(); $pkgList = array(); $noMod = array('.', '..'); $doc = new DOMDocument(); if (is_dir($pkgPath)) { $dp = opendir($pkgPath); while ($file = readdir($dp)) { if (!in_array($file, $noMod)) { $doc->load($pkgPath . DS . $file); if ($doc->documentElement->nodeName == Fox_Extensionmanager_Model_Generate_Package::PACKAGE_ROOT_ELEMENT && $doc->documentElement->childNodes) { $data = array(); $nList = $doc->documentElement->childNodes; foreach ($nList as $n) { if (in_array($n->nodeName, array(Fox_Extensionmanager_Model_Generate_Package::PACKAGE_NAME_ELEMENT, Fox_Extensionmanager_Model_Generate_Package::PACKAGE_VERSION_ELEMENT, Fox_Extensionmanager_Model_Generate_Package::PACKAGE_STABILITY_ELEMENT))) { $data[$n->nodeName] = $n->nodeValue; } } if ($data) { $pkgList[] = $data; } } } } } sort($pkgList); return $pkgList; }
/** * Send reply to contact request * * @param string $replyMessage */ public function reply($replyMessage) { $this->setStatus(Fox_Contact_Model_Contact::STATUS_REPLIED); $this->save(); $modelTemplate = Fox::getModel('core/email/template'); $modelTemplate->sendTemplateMail(Fox::getPreference('contact/reply/email_template'), $this->getEmail(), array('sender_email' => Fox::getPreference('contact/reply/email'), 'sender_name' => Fox::getPreference('contact/reply/name')), array('name' => $this->getName(), 'subject' => $this->getSubject(), 'message' => $this->getMessage(), 'reply' => $replyMessage)); }
/** * Get newsletter template content * * @return string */ public function getTemplateContent() { $id = $this->getRequest()->getParam('tId'); $model = Fox::getModel('newsletter/template'); $model->load($id); return $model->getContent(); }
/** * Render contents * * @return string */ public function render() { $args = func_get_args(); $changePwdImg = Fox::getThemeUrl('images/change_pwd.png'); $loginImg = Fox::getThemeUrl('images/login.png'); return '<a target="_self" href="' . $args[0]['change_password'] . '" title="' . $args[0]['change_password'] . '"><img src="' . $changePwdImg . '" alt="Change Password" title="Change Password" style="border:none;" /></a> <a target="_blank" href="' . $args[0]['login'] . '" title="' . $args[0]['login'] . '"><img src="' . $loginImg . '" alt="Login" title="Login" style="border:none;" /></a>'; }
/** * Traverses Files and Directories inside given path Recursively * @param $path to traverse */ public function traverseDirFiles($path) { $dir = opendir($path); $files = array(); $f = array(); $skip = array(Fox::getDirectoryPath() . DS . "var", Fox::getDirectoryPath() . DS . "library" . DS . "Zend", Fox::getExtensionDirectoryPath(), Fox::getDirectoryPath() . DS . "theme" . DS . "installer", APPLICATION_PATH . DS . "views" . DS . "installer"); while ($ft = readdir($dir)) { if (in_array($ft, array(".", "..")) || in_array($path . DS . $ft, $skip)) { continue; } $f[] = $ft; } sort($f); foreach ($f as $file) { if (filetype($path . DS . $file) != "dir") { $files[] = $file; } else { $this->traverseDirFiles($path . DS . $file); } } foreach ($files as $f) { $this->processFiles($path, $f); } closedir($dir); }
/** * Loades cms page of specified key * * @param Fox_Core_Controller_Action $controller * @param string $key * @return boolean */ public function routKey($controller, $key) { $page = Fox::getModel('cms/page'); $page->load($key, 'url_key'); if ($page->getId() && $page->getStatus()) { if (($container = $page->getLayout()) != '') { $layoutUpdate = '<container key="' . $container . '"/>'; } if (($lUpdate = $page->getLayoutUpdate()) != '') { $layoutUpdate .= $lUpdate; } $layout = $controller->loadLayout($layoutUpdate, $key); $layout->setTitle($page->getTitle()); $layout->setMetaKeywords($page->getMetaKeywords()); $layout->setMetaDescription($page->getMetaDescription()); if ($contentView = $controller->getViewByKey('content')) { $pageView = Fox::getView('cms/page'); $pageView->setPageContent($page->getContent()); $pageView->setPageTitle($page->getTitle()); $pageView->setPageUrlKey($page->getUrlKey()); $contentView->addChild('__page_content__', $pageView); } $controller->renderLayout(); $controller->getResponse()->setHeader('HTTP/1.1', '200 ok'); $controller->getResponse()->setHeader('Status', '200 ok'); $this->routingCompleted = TRUE; } return $this->routingCompleted; }
/** * Page not found action */ public function pageNotFoundAction() { $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found'); $this->getResponse()->setHeader('Status', '404 File not found'); if (!Fox::getHelper('core/router')->routKey($this, 'no-page-404')) { $this->_forward('nothing'); } }
/** * Prepare container */ protected function _prepareContainer() { parent::_prepareContainer(); $this->setIsEditButtonEnabled(FALSE); $this->setIsSaveButtonEnabled(FALSE); $this->setIsResetButtonEnabled(FALSE); $this->addButton(array('name' => 'reply', 'id' => 'reply', 'button_text' => 'Reply', 'style_class' => 'form-button', 'icon_class' => 'save', 'url' => Fox::getUrl('*/*/reply', array('id' => $this->getRequest()->getParam('id'))))); }
/** * Delete Modules * * @param array $modules Name of modules that needs to be deleted are passed as array values */ public function deleteModules($modules) { foreach ($modules as $moduleName) { $module = Fox::getModel('core/module'); $module->load($moduleName); $module->delete(); } }
/** * Render contents * * @return string */ public function render() { $args = func_get_args(); $url = $args[0]['preview_url']; $queueImg = Fox::getThemeUrl('images/queue.png'); $previewImg = Fox::getThemeUrl('images/preview.png'); $previewUrl = "window.open('" . $url . "','previewWindow','width=800,height=600')"; return '<a href="' . $args[0]['send_newsletter'] . '" title="' . $args[0]['send_newsletter'] . '"><img src="' . $queueImg . '" alt="Send Newsletter" title="Send Newsletter" style="border:none;" width="22" height="22"/></a> <a target="_blank" title="' . $args[0]['preview_url'] . '" title="' . $args[0]['preview_url'] . '" onclick="' . $previewUrl . '"><img src="' . $previewImg . '" alt="Preview" title="Preview" /></a>'; }
/** * Prepare form * * @param Uni_Core_Form_Eav $form */ protected function _prepareForm(Uni_Core_Form_Eav $form) { $form->setName('setting')->setMethod('post'); $model = Fox::getModel($this->getModelKey()); $eavMetaData = $model->getEavFormMetaData(); $form->createEavForm($eavMetaData); $form->setElementsBelongTo($model->getItem()); parent::_prepareForm($form); }
/** * Prepare model collection */ protected function _prepareCollection() { $model = Fox::getModel('admin/role'); $sortCondition = $this->getSortCondition(); $filters = $this->getSearchCriteria(); $collection = $model->getModelCollection($filters, '*', $sortCondition, $this->getColumns()); $this->setCollection($collection); parent::_prepareCollection(); }
/** * Prepare table columns */ protected function _prepareColumns() { $this->addColumn('id', array('label' => 'Id', 'align' => 'left', 'width' => 50, 'type' => self::TYPE_NUMBER, 'field' => 'id')); $this->addColumn('title', array('label' => 'Title', 'align' => 'left', 'field' => 'title')); $this->addColumn('identifier_key', array('label' => 'Identifier Key', 'align' => 'left', 'field' => 'identifier_key')); $this->addColumn('status', array('label' => 'Status', 'align' => 'center', 'width' => 100, 'type' => self::TYPE_OPTIONS, 'options' => Fox::getModel('cms/block')->getAllStatuses(), 'field' => 'status')); $this->addColumn('created_on', array('label' => 'Created On', 'align' => 'center', 'width' => 182, 'type' => self::TYPE_DATE, 'field' => 'created_on')); $this->addColumn('modified_on', array('label' => 'Modified On', 'align' => 'center', 'width' => 182, 'type' => self::TYPE_DATE, 'field' => 'modified_on')); parent::_prepareColumns(); }
/** * Get parsed cms block content * * @param string $identifierKey * @return string */ public function getBlockContent($identifierKey) { $parsedContent = NULL; $model = Fox::getModel('cms/block'); $model->load($identifierKey, 'identifier_key'); if ($model->getId() && $model->getStatus() == Fox_Cms_Model_Block::STATUS_ENABLED) { $parsedContent = $this->view->getParsedContent($model->getContent()); } return $parsedContent; }
/** * Get menu html * * @return string */ function getMenuMarkup() { $markup = ''; $settingModel = Fox::getModel('admin/system/setting/config'); if ($settingModel) { $settingModel->loadSettingData($this->getRequest()->getParam('item', 'general')); $markup = $settingModel->getMenuMarkup(); } return $markup; }
/** * Prepare container */ protected function _prepareContainer() { if (Fox::getModel('extensionmanager/session')->getFormData()) { $this->editing = true; $this->addButton(array("type" => "button", "button_text" => "Generate Package", "url" => $this->getUrl("*/*/generate-package"), "style_class" => "form-button", "confirm" => true, "confirm_text" => "Unsaved changes to package may lost.")); } $this->deleteButtonUrl = Fox::getUrl("*/*/delete"); $this->setIsDeleteButtonEnabled(TRUE); parent::_prepareContainer(); }
/** * Controller predispatch method * * Called before action method */ function preDispatch() { parent::preDispatch(); if (!Fox::getModel('member/session')->getLoginData()) { if (!('member' === strtolower($this->getRequest()->getModuleName()) && 'account' === strtolower($this->getRequest()->getControllerName()) && 'login' === strtolower($this->getRequest()->getActionName())) && !('member' === strtolower($this->getRequest()->getModuleName()) && 'account' === strtolower($this->getRequest()->getControllerName()) && 'create' === strtolower($this->getRequest()->getActionName())) && !('member' === strtolower($this->getRequest()->getModuleName()) && 'account' === strtolower($this->getRequest()->getControllerName()) && 'forgot-password' === strtolower($this->getRequest()->getActionName())) && !('member' === strtolower($this->getRequest()->getModuleName()) && 'account' === strtolower($this->getRequest()->getControllerName()) && 'verification' === strtolower($this->getRequest()->getActionName())) && !('member' === strtolower($this->getRequest()->getModuleName()) && 'account' === strtolower($this->getRequest()->getControllerName()) && 'change-forget-password' === strtolower($this->getRequest()->getActionName()))) { $this->sendRedirect('member/account/login'); } } else { Fox::getModel('member/session')->setSessionTimeout(Fox::getMemberSessionInterval()); } }
/** * Get parsed block content * * @return string */ public function getBlockContent() { if (NULL == $this->parsedContent) { $model = Fox::getModel('cms/block'); $model->load($this->getViewKey(), 'identifier_key'); if ($model->getId() && $model->getStatus() == Fox_Cms_Model_Block::STATUS_ENABLED) { $this->blockContent = $model->getContent(); $this->parsedContent = stripslashes($this->getParsedContent($this->blockContent)); } } return $this->parsedContent ? $this->parsedContent : ''; }
/** * Prepare table columns */ protected function _prepareColumns() { $this->addColumn('id', array('label' => 'Id', 'align' => 'left', 'type' => self::TYPE_NUMBER, 'width' => 50, 'field' => 'id')); $this->addColumn('title', array('label' => 'Title', 'align' => 'left', 'field' => 'title')); $this->addColumn('url_key', array('label' => 'URL Key', 'align' => 'left', 'field' => 'url_key')); $this->addColumn('layout', array('label' => 'Layout', 'align' => 'left', 'width' => 120, 'field' => 'layout', 'type' => self::TYPE_OPTIONS, 'options' => Fox::getModel('cms/page')->getAvailableLayouts())); $this->addColumn('status', array('label' => 'Status', 'align' => 'center', 'width' => 70, 'type' => self::TYPE_OPTIONS, 'options' => Fox::getModel('cms/page')->getAllStatuses(), 'field' => 'status')); $this->addColumn('created', array('label' => 'Created On', 'align' => 'center', 'width' => 182, 'type' => self::TYPE_DATE, 'field' => 'created')); $this->addColumn('modified_on', array('label' => 'Modified On', 'align' => 'center', 'width' => 182, 'type' => self::TYPE_DATE, 'field' => 'modified_on')); $this->addColumn('page_action', array('label' => 'Action', 'width' => 70, 'filter' => FALSE, 'align' => 'center', 'field' => 'page_action', 'renderer' => 'cms/admin/page/table/renderer/action')); parent::_prepareColumns(); }
/** * Prepare form * * @param Uni_Core_Form_Eav $form */ protected function _prepareForm(Uni_Core_Form_Eav $form) { $form->setName('member')->setMethod('post'); $model = Fox::getModel($this->getModelKey()); if (Fox::getLoggedMember()) { $model->load(Fox::getLoggedMember()->getId()); } $eavMetaData = $model->getEavFormMetaData(1, Fox_Eav_Model_Abstract::EDITABLE_TYPE_FRONTEND); $form->createEavForm($eavMetaData); $form->addPrefixPath('Uni_Core_Admin_View_Form_Decorator', 'Uni/Core/Admin/View/Form/Decorator/', 'decorator'); $form->setDecorators(array('Tabs')); parent::_prepareForm($form); }
/** * Get tree view object * * @return Fox_Eav_View_Admin_Set_Edit_Tree */ public function getTree() { if ($tree = $this->getChild(self::FORM_KEY)) { return $tree; } else { $formClass = get_class($this) . '_Tree'; $formView = Fox::getView($formClass); if ($formView) { $this->addChild(self::FORM_KEY, $formView); return $formView; } } }
/** * Check stability is reliable * * @return boolean */ private function isReliableStability() { $packageInfo = $this->getViewOptions('package'); if (isset($packageInfo['stability']) && $packageInfo['stability']) { if ($packageInfo['stability'] >= Fox::getPreference('extensionmanager/downloader/preferred_state')) { return true; } else { $this->messages[] = "This extension is under " . Fox::getModel('extensionmanager/package/state')->getOptionText($packageInfo['stability']) . " state"; } } else { $this->messages[] = "Unknown stability"; } return false; }
/** * Load module settings data * * @param boolean $forceCreate * @return array */ public static function loadPreferences($forceCreate = FALSE) { if (!$forceCreate && !empty(self::$preferences)) { self::$preferences; } $ds = DIRECTORY_SEPARATOR; $preferenceFilePath = CACHE_DIR . $ds . Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE; $fileName = 'preference.xml'; self::$preferences = array(); $xDom = new Uni_Data_XDOMDocument(); $cacheSettings = Uni_Core_CacheManager::loadCacheSettings(); $isCacheEnabled = isset($cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE]) ? $cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE] : FALSE; if ($forceCreate || !$isCacheEnabled || !file_exists($preferenceFilePath . $ds . $fileName)) { if (!file_exists($preferenceFilePath)) { if (!@mkdir($preferenceFilePath, 0777, TRUE)) { throw new Exception('"' . $preferenceFilePath . '" not found'); } } $xDom->preserveWhiteSpace = false; $xDom->formatOutput = true; $preferenceModel = Fox::getModel('core/preference'); $collection = $preferenceModel->getCollection(); $root = $xDom->createElement('preferences'); foreach ($collection as $preference) { self::$preferences[$preference['name']] = $preference['value']; $cData = $xDom->createCDATASection(''); $cData->appendData($preference['value']); $entry = $xDom->createElement('entry'); $entry->setAttribute('key', $preference['name']); $root->appendChild($entry); $entry->appendChild($cData); } $xDom->appendChild($root); $doc = $xDom->save($preferenceFilePath . $ds . $fileName); @chmod($preferenceFilePath, 0777); } else { $xDom->load($preferenceFilePath . $ds . $fileName); if ($xDom->documentElement->hasChildNodes()) { $nodeList = $xDom->documentElement->childNodes; foreach ($nodeList as $n) { if ($n->nodeType == XML_ELEMENT_NODE && ($key = $n->getAttribute('key'))) { self::$preferences[$key] = $n->nodeValue; } } } } unset($xDom); return self::$preferences; }
/** * Send newsletter to subscribers */ public function sendNewsletter() { $subscriberModel = Fox::getModel('newsletter/subscriber'); $subscriberCollection = $subscriberModel->getCollection('status=' . Fox_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED); $currDate = Fox_Core_Model_Date::getCurrentDate('Y-m-d H:i:s'); $modelTemplate = Fox::getModel('core/email/template'); foreach ($subscriberCollection as $subscriber) { $subject = $modelTemplate->getParsedContent($this->getSubject(), array('email' => $subscriber['email'], 'name' => $subscriber['name'])); $message = $modelTemplate->getParsedContent($this->getContent(), array('email' => $subscriber['email'], 'name' => $subscriber['name'])); $modelTemplate->sendMail($subscriber['email'], $this->getSenderEmail(), $this->getSenderName(), $subject, $message); } $this->setStatus(Fox_Newsletter_Model_Template::STATUS_SENT); $this->setLastSent($currDate); $this->save(); }
/** * Get Selected tree nodes * * @return array */ public function getSelectedTreeNodes() { $treeSelected = array(); $data = Fox::getModel('extensionmanager/session')->getFormData(); if (isset($data['content_tree_data']) && $data['content_tree_data']) { $treeDom = Uni_Data_XDOMDocument::loadXML($data['content_tree_data']); foreach ($treeDom->documentElement->childNodes as $node) { if ($node->nodeName == "#text") { continue; } $treeSelected[] = $node->getAttribute("path"); } } return $treeSelected; }
/** * Prepare form * * @param Uni_Core_Form_Eav $form */ protected function _prepareForm(Uni_Core_Form_Eav $form) { $form->setName('member')->setMethod('post'); $model = Fox::getModel($this->getModelKey()); $id = $this->getRequest()->getParam('id', FALSE); $edit = 0; if ($id) { $model->load($id); if ($model->getId()) { $edit = Fox_Eav_Model_Abstract::EDITABLE_TYPE_BACKEND; } } $eavMetaData = $model->getEavFormMetaData(1, $edit); $form->createEavForm($eavMetaData); parent::_prepareForm($form); }
/** * Switches url to http/https automatically as per application setting * */ public function direct() { $request = $this->getRequest(); $scheme = $request->getScheme(); if ($scheme == 'http' && Fox::isSecureUrlEnabled()) { $url = 'https://' . $request->getServer('SERVER_NAME') . $request->getRequestUri(); $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoUrl($url); } else { if ($scheme == 'https' && !Fox::isSecureUrlEnabled()) { $url = 'http://' . $request->getServer('SERVER_NAME') . $request->getRequestUri(); $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoUrl($url); } } }
/** * Matches a user submitted path. Assigns and returns an array of variables * on a successful match. * * If a request object is registered, it uses its setModuleName(), * setControllerName(), and setActionName() accessors to set those values. * Always returns the values as an array. * * @param string $path Path used to match against this routing map * @return array An array of assigned values or a false on a mismatch */ public function match($path, $partial = false) { $this->_setRequestKeys(); $values = array(); $params = array(); if (!$partial) { $path = trim($path, self::URI_DELIMITER); } else { $matchedPath = $path; } if ($path != '') { $path = explode(self::URI_DELIMITER, $path); $adminKey = Fox::getAdminKey(); $adminModule = 'admin'; if ($path[0] == $adminKey) { $path[0] = $adminModule; } else { if ('admin' == $path[0]) { $path[0] = FALSE; } } if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) { $values[$this->_moduleKey] = array_shift($path); $this->_moduleValid = true; } if (count($path) && !empty($path[0])) { $values[$this->_controllerKey] = array_shift($path); } if (count($path) && !empty($path[0])) { $values[$this->_actionKey] = array_shift($path); } if ($numSegs = count($path)) { for ($i = 0; $i < $numSegs; $i = $i + 2) { $key = urldecode($path[$i]); $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null; $params[$key] = isset($params[$key]) ? array_merge((array) $params[$key], array($val)) : $val; } } } if ($partial) { $this->setMatchedPath($matchedPath); } $this->_values = $values + $params; return $this->_values + $this->_defaults; }