/** * Taken from php.net * * @param type $folder * @param type $zipFile * @param type $subfolder * @return boolean */ public static function folderToZip($folder, &$zipFile, $subfolder = null) { if ($zipFile == null) { // no resource given, exit return false; } // we check if $folder has a slash at its end, if not, we append one $folder .= end(str_split($folder)) == "/" ? "" : "/"; $subfolder .= end(str_split($subfolder)) == "/" ? "" : "/"; // we start by going through all files in $folder $handle = opendir($folder); while ($f = readdir($handle)) { if ($f != "." && $f != "..") { if (is_file($folder . $f)) { // if we find a file, store it // if we have a subfolder, store it there if ($subfolder != null) { $zipFile->addFile($folder . $f, $subfolder . $f); } else { $zipFile->addFile($folder . $f); } } elseif (is_dir($folder . $f)) { // if we find a folder, create a folder in the zip $zipFile->addEmptyDir($f); // and call the function again self::folderToZip($folder . $f, $zipFile, $f); } } } }
/** * connect to database -- using Eloquent * @param type $capsule * @return type */ public function connectToDatabase($capsule) { // Register Eloquent configuration $capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'ch', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci']); $capsule->bootEloquent(); return $capsule; }
/** * (dispatcher hook) * Check recieved file sequences * @param type $receiver * @param type $filepaths * @param type $hostname * @return type */ public function afterFTPReceived($receiver, $filepaths, $hostname) { if ($receiver->getType() != $this->getName()) { return; } $this->checkFilesSeq($filepaths, $hostname); }
/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $dept_id = $this->user !== NULL ? Users::model()->getDeptId($this->user->id) : NULL; if ($this->user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($this->user->validatePassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { if ($this->user->status === Users::STATUS_BLOCKED) { $this->errorCode = self::ERROR_ACC_BLOCKED; } else { if ($this->user->status === Users::STATUS_PENDING) { $this->errorCode = self::ERROR_ACC_PENDING; } else { if (!empty($dept_id) && Dept::model()->get($dept_id, 'status') === Dept::STATUS_CLOSED) { $this->errorCode = self::ERROR_DEPT_CLOSED; } else { $this->completeLogin($dept_id); } } } } } return $this->errorCode === self::ERROR_NONE; }
/** * Oštítkuje danou stránku (nebo skupinu stránek) lokálním / globálním * štítkem. * * Pokud je štítek rekurzivní, tak podstránky štítkuje pasivně. * * @param type $page * @param type $level * @param type $data * @return type */ public function label($page, $level, $data) { $depthOfRecursion = $this->label['depth_of_recursion']; $maxLevelOfRecursion = $this->label['depth_of_recursion'] + 1; if ($level == 1) { if ($this->assign) { $page->assignActiveLabel($this->label['label_id']); // if ($this->label['is_global']) { // $pm = $page->presenter->context->pageManager; // $pages = $pm->getPageGroup($page->getProperty('lg')); // foreach ($pages as $page) { // $page->assignActiveLabel($this->label['label_id']); // } // } else { // $page->assignActiveLabel($this->label['label_id']); // } } else { $page->removeActiveLabel($this->label['label_id']); // if ($this->label['is_global']) { // $pm = $page->presenter->context->pageManager; // $pages = $pm->getPageGroup($page->getProperty('lg')); // foreach ($pages as $page) { // $page->removeActiveLabel($this->label['label_id']); // } // } else { // $page->removeActiveLabel($this->label['label_id']); // } } } else { if ($depthOfRecursion === NULL) { return NULL; } if ($depthOfRecursion == 0 || $level <= $maxLevelOfRecursion) { if ($this->assign) { $page->assignPassiveLabel($this->label['label_id']); // if ($this->label['is_global']) { // $pm = $page->presenter->context->pageManager; // $pages = $pm->getPageGroup($page->getProperty('lg')); // foreach ($pages as $page) { // $page->assignPassiveLabel($this->label['label_id']); // } // } else { // $page->assignPassiveLabel($this->label['label_id']); // } } else { $page->removePassiveLabel($this->label['label_id']); // if ($this->label['is_global']) { // $pm = $page->presenter->context->pageManager; // $pages = $pm->getPageGroup($page->getProperty('lg')); // foreach ($pages as $page) { // $page->removePassiveLabel($this->label['label_id']); // } // } else { // $page->removePassiveLabel($this->label['label_id']); // } } } } $page->refresh(); }
/** * Called on the login user event * Checks for spammers * * @param type $event * @param type $type * @param type $user * @return boolean */ function login_event($event, $type, $user) { $check_login = elgg_get_plugin_setting('event_login', PLUGIN_ID); $ip = get_ip(); $user->ip_address = $ip; if ($check_login != 'no' || !$user->last_login) { // do it by default if (!check_spammer($user->email, $ip, true) && !$user->isAdmin()) { register_error(elgg_echo('spam_login_filter:access_denied_mail_blacklist')); notify_admin($user->email, $ip, "Existing member identified as spammer has tried to login, check this account"); return false; } } // check user metadata for banned words/phrases $banned = get_banned_strings(); $metadata = get_metadata_names(); if ($banned && $metadata) { foreach ($metadata as $m) { foreach ($banned as $str) { if (strpos($user->{$m}, $str) !== false) { return false; } } } } }
/** * * @param type $oObj * @param type $sCss * @return type */ public function generateAdminLinks($oObj, $sCss) { JCH_DEBUG ? JchPlatformProfiler::start('GenerateAdminLinks') : null; $params = clone $this->params; $params->set('javascript', '1'); $params->set('css', '1'); $params->set('excludeAllExtensions', '0'); $params->set('css_minify', '0'); $params->set('debug', '0'); $params->set('bottom_js', '2'); ##<procode>## $params->set('pro_phpAndExternal', '1'); $params->set('pro_inlineScripts', '1'); $params->set('pro_lazyload', '0'); ##</procode>## $sHtml = $oObj->getOriginalHtml(); $oParser = new JchOptimizeParser($params, $sHtml, JchOptimizeFileRetriever::getInstance()); $aLinks = $oParser->getReplacedFiles(); if ($sCss == '' && !empty($aLinks['css'][0])) { $oCombiner = new JchOptimizeCombiner($params, $this->bBackend); $oCssParser = new JchOptimizeCssParser($params, $this->bBackend); $oCombiner->combineFiles($aLinks['css'][0], 'css', $oCssParser); $sCss = $oCombiner->css; } $oSpriteGenerator = new JchOptimizeSpriteGenerator($params); $aLinks['images'] = $oSpriteGenerator->processCssUrls($sCss, TRUE); ##<procode>## $sRegex = $oParser->getLazyLoadRegex(); preg_match_all($sRegex, $oParser->getBodyHtml(), $aMatches); $aLinks['lazyload'] = $aMatches[1]; ##</procode>## JCH_DEBUG ? JchPlatformProfiler::stop('GenerateAdminLinks', TRUE) : null; return $aLinks; }
/** * CMS block cache, must use the block id from the database * * @param type $block */ public function applyCmsBlock($block) { // The "messages" block is session-dependent, don't cache if (Mage::helper('cache')->responseHasMessages()) { $block->setData('cache_lifetime', null); return; } // Set cache tags $tags = array(); $blockId = $block->getData('block_id'); if ($blockId) { $cmsBlock = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockId); if ($cmsBlock->getIsActive()) { $tags = $block->getCacheTags(); $tags[] = Mage_Cms_Model_Block::CACHE_TAG . '_' . $cmsBlock->getId(); } } $block->setData('cache_tags', $tags); // Set cache key $keys = $block->getCacheKeys(); $blockId = $block->getData('block_id'); if ($blockId) { $cmsBlock = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockId); if ($cmsBlock->getIsActive()) { $keys = $block->getCacheKeyInfo(); if (!is_array($keys)) { $keys = array(); } $keys[] = $blockId; $keys[] = $block->getLayout()->getUpdate()->getCacheId(); } } $block->setData('cache_keys', $keys); }
/** * check product options when version >= 1.5 * @param type $itemId * @param type $option * @param type $qty * @param type $cartService * @return boolean * @author hujs */ public function beforeAction($itemId, $option, $qty, $cartService) { $error = $cartService->checkMinimunOrder($itemId, (int) $qty); if (sizeof($error)) { return $error; } $this->language->load('checkout/cart'); $this->load->model('catalog/product'); $productOptions = $this->model_catalog_product->getProductOptions($itemId); foreach ($productOptions as $productOption) { $optionId = $productOption['product_option_id']; if ($productOption['required'] && (!isset($option[$optionId]) || !$option[$optionId])) { $error[] = sprintf($this->language->get('error_required'), $productOption['name']); } else { switch ($productOption['type']) { case 'date': case 'time': case 'datetime': $date = str_replace('//', '/', $option[$optionId]); $result = date_parse($date); $result['error_count'] > 0 && ($error[] = $productOption['name'] . ' Invalid.'); break; case 'file': $this->uploadFile($option[$optionId], $error); break; default: break; } } } return sizeof($error) ? $error : true; }
/** * Convert to form value. * * @param type $value */ public function transform($value) { if ($value === null) { return; } return $value->getId(); }
/** * Executes the widget. */ public function run() { if (Yii::app()->user->isGuest) { return; } $this->render('notificationSwitchLink', array('content' => $this->content, 'state' => $this->content->isFollowedByUser(Yii::app()->user->id, true))); }
/** * Gets all fixtures files */ protected function loadFixtureFiles() { foreach ($this->bundles as $bundle) { $path = $this->kernel->locateResource('@' . $bundle); $files = glob($path . 'DataFixtures/*.yml'); $this->fixture_files = array_merge($this->fixture_files, $files); //sort by index $sortedFiles = array(); $sortingIndex = @file_get_contents($path . 'DataFixtures/fixturesOrder.txt'); if (!empty($sortingIndex)) { $sortingIndex = explode("\n", $sortingIndex); // pick indexed foreach ($sortingIndex as $name) { foreach ($this->fixture_files as $key => $fixture_file) { if (strcmp(basename($fixture_file), $name . '.yml') === 0) { $sortedFiles[] = $fixture_file; unset($this->fixture_files[$key]); } } } // append the rest if (!empty($this->fixture_files)) { foreach ($this->fixture_files as $fixture_file) { $sortedFiles[] = $fixture_file; } } $this->fixture_files = $sortedFiles; } } }
/** * * @param type $request */ public function execute($request) { $request->setParameter('initialActionName', $this->getInitalAction()); $this->_setListComponent($this->getPerformanceTrackList(), $this->getTrackerListCount()); $params = array(); $this->parmetersForListCompoment = $params; }
/** * Método estático que permite registrar una actividad * @param type $model modelo en donde se realiza la actividad * @param type $tipo tipo de actividad (update,create,delete) * @param type $usuario_id usuario que realiza la actividad, opcional * @param type $detalle mensaje extra sobre el detalle de la actividad, opcional * @return type Boolean devuelve un true o false si guarda o no la actividad */ public static function registrarActividad($model, $tipo, $usuario_id = null, $detalle = null) { $actividad = new ActividadSistema(); $actividad->attributes = array('entidad_tipo' => $model->tableName(), 'entidad_id' => $model->id, 'tipo' => $tipo, 'usuario_id' => $usuario_id ? $usuario_id : $model->usuario_creacion_id, 'fecha' => Util::FechaActual()); $actividad->detalle = $detalle ? $detalle : null; return $actividad->save(); }
/** * transfer reward points discount to Paypal gateway * * @param type $observer */ public function paypalPrepareLineItems($observer) { if (version_compare(Mage::getVersion(), '1.4.2', '>=')) { if ($paypalCart = $observer->getPaypalCart()) { $salesEntity = $paypalCart->getSalesEntity(); $baseDiscount = $salesEntity->getRewardpointsInvitedBaseDiscount(); if ($baseDiscount < 0.0001 && $salesEntity instanceof Mage_Sales_Model_Quote) { $baseDiscount = Mage::getSingleton('checkout/session')->getRewardpointsInvitedBaseDiscount(); } if ($baseDiscount > 0.0001) { $paypalCart->updateTotal(Mage_Paypal_Model_Cart::TOTAL_DISCOUNT, (double) $baseDiscount, Mage::helper('rewardpointsreferfriends')->__('Offer Discount')); } } return $this; } $salesEntity = $observer->getSalesEntity(); $additional = $observer->getAdditional(); if ($salesEntity && $additional) { $baseDiscount = $salesEntity->getRewardpointsBaseDiscount(); if ($baseDiscount > 0.0001) { $items = $additional->getItems(); $items[] = new Varien_Object(array('name' => Mage::helper('rewardpointsreferfriends')->__('Offer Discount'), 'qty' => 1, 'amount' => -(double) $baseDiscount)); $additional->setItems($items); } } }
/** * Sortable taxonomy columns * Credit: http://scribu.net/wordpress/sortable-taxonomy-columns.html * Modified to suit our purpose * Allows us to sort the gallery listing by * Slightly modified to fit our purpose * * @global type $wpdb * @param type $clauses * @param type $wp_query * @return type */ function mpp_taxonomy_filter_clauses($clauses, $wp_query) { //only apply if we are on the mpp gallery list screen if (!mpp_admin_is_gallery_list()) { return $clauses; } if (!isset($wp_query->query['orderby'])) { return $clauses; } $order_by = $wp_query->query['orderby']; $order_by_tax = mpp_translate_to_taxonomy($order_by); if (!$order_by_tax || !in_array($order_by, array('component', 'status', 'type'))) { return $clauses; } global $wpdb; //if we are here, It is for one of our taxonomy $clauses['join'] .= <<<SQL LEFT OUTER JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID={$wpdb->term_relationships}.object_id LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id) LEFT OUTER JOIN {$wpdb->terms} USING (term_id) SQL; $clauses['where'] .= $wpdb->prepare(" AND (taxonomy = %s OR taxonomy IS NULL)", $order_by_tax); $clauses['groupby'] = "object_id"; $clauses['orderby'] = "GROUP_CONCAT({$wpdb->terms}.name ORDER BY name ASC) "; $clauses['orderby'] .= 'ASC' == strtoupper($wp_query->get('order')) ? 'ASC' : 'DESC'; return $clauses; }
/** * Sets order STATE based on status. * * @param type $o */ public function orderState($o) { $order = $o->getEvent()->getOrder(); if (!is_object($order->getPayment())) { return $o; } $_c = $order->getPayment()->getMethod(); if (Mage::helper('sagepaysuite')->isSagePayMethod($_c) === false) { return $o; } $methodInstance = $order->getPayment()->getMethodInstance(); $methodInstance->setStore($order->getStoreId()); $action = $methodInstance->getConfigPaymentAction(); $state = Mage_Sales_Model_Order::STATE_NEW; if ($action == Ebizmarts_SagePaySuite_Model_Api_Payment::ACTION_AUTHORIZE_CAPTURE or $action == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) { $state = Mage_Sales_Model_Order::STATE_PROCESSING; } $order->setState($state); /* Set order status based on ReD response. * $sagedata = $this->_getTransactionsModel()->loadByParent($order->getId()); $ReD = $sagedata->getRedFraudResponse(); if(strtoupper($ReD) == 'DENY') { $order->setStatus('security_check'); }*/ }
/** * Checks that a result is successful * * @param type $result * @throws CMError */ protected function checkResult($result) { if (!$result->was_successful()) { throw new CMError($result->response->Message, $result->http_status_code); } return true; }
/** * * @param type $manager * @param type $v */ public function populateDogodekSplosni($manager, $v) { $rep = $manager->getRepository('Koledar\\Entity\\DogodekSplosni'); $o = null; $nov = false; if (!$o) { $o = new \Koledar\Entity\DogodekSplosni(); $nov = true; } $o->setTitle($v[1]); $o->setStatus($v[2]); $date = empty($v[3]) ? null : date_create($v[3]); $o->setZacetek($date); $date = empty($v[4]) ? null : date_create($v[4]); $o->setKonec($date); $ref = $v[5] ? $this->getReference($v[5]) : null; $o->setProstor($ref); $ref = $v[6] ? $this->getReference($v[6]) : null; // $o->setSezona($ref); if ($nov) { $rep->create($o); } else { $rep->update($o); } $referenca = 'DogodekSplosni-' . $v[0]; // var_dump($referenca); $this->addReference($referenca, $o); $referencaDog = 'DogodekSpl-' . $v[0]; $this->addReference($referencaDog, $o->getDogodek()); }
/** * Constructor * @param type $a_parent_obj * @param type $a_parent_cmd * @param type $a_template_context */ public function __construct($a_parent_obj_gui, $a_parent_obj, $a_parent_cmd) { $this->parent_container = $a_parent_obj; $this->setId('lomemtstres_' . $a_parent_obj->getId()); parent::__construct($a_parent_obj_gui, $a_parent_cmd); $this->settings = ilLOSettings::getInstanceByObjId($a_parent_obj->getId()); }
/** * Called on successful user login * If they are not in stormpath lets add them * * @param type $event * @param type $type * @param type $user */ function event_user_login($event, $type, $user) { $access_status = access_get_show_hidden_status(); access_show_hidden_entities(TRUE); if ($user instanceof ElggUser && !$user->isEnabled() && !$user->validated) { // send new validation email uservalidationbyemail_request_validation($user->getGUID()); // restore hidden entities settings access_show_hidden_entities($access_status); // throw error so we get a nice error message throw new LoginException(elgg_echo('uservalidationbyemail:login:fail')); } access_show_hidden_entities($access_status); if ($user->__stormpath_user) { return true; } // search stormpath for a matching account // may be in stormpath by manual addition, or from another application // with shared login $application = get_application(); if ($application) { $accts = $application->getAccounts(array('email' => $user->email)); foreach ($accts as $a) { $user->__stormpath_user = $a->href; return true; } $password = get_input('password'); if ($password) { add_to_stormpath($user, $password); } } return true; }
/** * * @param type $oObj * @param type $sCss * @return type */ public function generateAdminLinks($oObj, $sCss) { JCH_DEBUG ? JchPlatformProfiler::start('GenerateAdminLinks') : null; $params = clone $this->params; $params->set('combine_files_enable', '1'); $params->set('javascript', '1'); $params->set('css', '1'); $params->set('gzip', '0'); $params->set('css_minify', '0'); $params->set('js_minify', '0'); $params->set('html_minify', '0'); $params->set('defer_js', '0'); $params->set('debug', '0'); $params->set('bottom_js', '2'); $params->set('includeAllExtensions', '1'); $params->set('excludeCss', array()); $params->set('excludeJs', array()); $params->set('excludeCssComponents', array()); $params->set('excludeJsComponents', array()); $params->set('csg_exclude_images', array()); $params->set('csg_include_images', array()); $sHtml = $oObj->getOriginalHtml(); $oParser = new JchOptimizeParser($params, $sHtml, JchOptimizeFileRetriever::getInstance()); $aLinks = $oParser->getReplacedFiles(); if ($sCss == '' && !empty($aLinks['css'][0])) { $oCombiner = new JchOptimizeCombiner($params, $this->bBackend); $oCssParser = new JchOptimizeCssParser($params, $this->bBackend); $oCombiner->combineFiles($aLinks['css'][0], 'css', $oCssParser); $sCss = $oCombiner->css; } $oSpriteGenerator = new JchOptimizeSpriteGenerator($params); $aLinks['images'] = $oSpriteGenerator->processCssUrls($sCss, TRUE); JCH_DEBUG ? JchPlatformProfiler::stop('GenerateAdminLinks', TRUE) : null; return $aLinks; }
/** * Execute /../stock/listItem * * @param type $request */ public function execute($request) { $head = sfYaml::load(sfConfig::get('sf_app_dir') . '/lib/list/item_list.yml'); $itemlist_headers = array($head['listItem']['header1'], $head['listItem']['header2'], $head['listItem']['header3'], $head['listItem']['header6']); $columns = 'id,name,sales_unit_price,stock_available'; $recordsLimit = 5; //have to take from lists if (!$request->hasParameter('pageNo')) { $pageNo = 1; } else { $pageNo = $request->getParameter('pageNo', 1); } $pager = new SimplePager('Item', $recordsLimit); $pager->setPage($pageNo); $pager->setNumResults($this->getItemService()->countItems()); $pager->init(); $offset = $pager->getOffset(); $offset = empty($offset) ? 0 : $offset; $paramHolder = new sfParameterHolder(); $paramHolder->set('columns', $columns); $paramHolder->set('offset', $offset); $paramHolder->set('limit', $recordsLimit); $itemlist_data = $this->getItemService()->getItems($paramHolder); $listContainer = new ListContainer(); $listContainer->setListName('ItemList'); $listContainer->setListHeaders($itemlist_headers); $listContainer->setListContent($itemlist_data); $listContainer->setRowLink("stock/showItem?id="); $listContainer->setPager($pager); $this->listcontainer = $listContainer; }
/** * Método que verifica se o usuario está logado * @param type $e */ public function validaAutenticacao($e) { $authenticateService = new \Zend\Authentication\AuthenticationService(); $authenticateService->setStorage(new \Zend\Authentication\Storage\Session("Semente")); $sessao = new \Zend\Session\Container("Semente"); $controller = $e->getTarget(); $em = $controller->getServiceLocator()->get('ZeDbManager'); $rotaAcessada = $controller->getEvent()->getRouteMatch()->getMatchedRouteName(); //erro 404: http://pensadores.local:8080/colunas/pensando-cabeca/100 /** Liberando rota para não precisar de autenticação */ $rota_livre = in_array($rotaAcessada, ['acesso/login', 'acesso/logout', 'acesso/nao-autorizado']); if ($rota_livre) { return true; } else { if (!$authenticateService->hasIdentity()) { $controller->redirect()->toRoute("acesso/login"); } else { $controlador = $controller->params()->fromRoute('controller'); $action = $controller->params()->fromRoute('action'); $user = $authenticateService->getIdentity()['cliente']; $esta_autorizado = TRUE; if (!$esta_autorizado) { return $controller->redirect()->toRoute("acesso/nao-autorizado", array('controlador' => $controlador, 'acao' => $action)); } } } }
/** * Returns the path to the template file. * * The file locator is used to locate the template when the naming convention * is the symfony one (i.e. the name can be parsed). * Otherwise the template is located using the locator from the twig library. * * @param string|TemplateReferenceInterface $template The template * * @throws \Twig_Error_Loader if the template could not be found * * @return string The path to the template file */ protected function findTemplate($template) { $logicalName = (string) $template; if (isset($this->cache[$logicalName])) { return $this->cache[$logicalName]; } $file = null; $previous = null; try { $template = $this->parser->parse($template); try { $file = $this->locator->locate($template); } catch (\InvalidArgumentException $e) { $previous = $e; } } catch (\Exception $e) { try { $file = parent::findTemplate($template); } catch (\Twig_Error_Loader $e) { $previous = $e; } } if (false === $file || null === $file) { throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $logicalName), -1, null, $previous); } return $this->cache[$logicalName] = $file; }
/** * Change title of Inventoryplus * * @param type $observer */ public function inventoryplus_before_show_title($observer) { $title = $observer->getEvent()->getTitle(); $text = '<h3><a href="javascript:void(0);" onclick="showDashboardMenu();">' . '<span><i class="fa fa-th"></i> ERP Plus | Inventory Management </span></a></h3>'; $text .= '<div id="erp_menu_dashboard">' . Mage::app()->getLayout()->createBlock('erpplus/adminhtml_dashboard')->setTemplate('erp_plus/page/dashboard-menu.phtml')->toHtml() . '</div>'; $title->setText($text); }
/** * Create one element * * @param type $node */ private function _generateElement($node) { if (!$node->isAllow()) { return; } $cssClasses = array(); $cssActive = ''; if ($node->isActive()) { $cssActive = 'class="active"'; } if (!is_null($node->getClass())) { $cssClasses[] = $node->getClass(); } $class = count($cssClasses) > 0 ? " class='" . implode(',', $cssClasses) . "'" : ''; $id = !is_null($node->getId()) ? " id='" . $node->getId() . "'" : ''; $target = !is_null($node->getTarget()) ? " target='" . $node->getTarget() . "'" : ''; $this->html .= "\t\t" . '<li ' . $cssActive . '>' . PHP_EOL; if (!$node->hasChilds()) { $this->html .= "\t\t\t" . '<a href="' . $node->getUrl() . '" ' . $target . ' class="nav-header" ><span' . $class . '></span> ' . $this->_translate($node->getName()) . "</a>" . PHP_EOL; } //generate childs if ($node->hasChilds()) { //$this->html .= "\t\t<div class='dropdown'>" . PHP_EOL; $this->html .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' . $this->_translate($node->getName()) . ' <span class="caret"></span></a>' . PHP_EOL; $this->html .= "\t\t<ul class=\"dropdown-menu\">" . PHP_EOL; $this->_generateChilds($node->getChilds()); $this->html .= "\t\t</ul>" . PHP_EOL; //$this->html .= "\t\t</div>" . PHP_EOL; } $this->html .= "\t\t</li>" . PHP_EOL; }
/** * Register action * @param type $data * @param type $form * @return \SS_HTTPResponse */ public function doRegister($data, $form) { $r = new EventRegistration(); $form->saveInto($r); $r->write(); return "Thanks. We've received your registration."; }
/** * Clones the custom layout of a parent group, for a newly created subgroup * @param type $group * @param type $parent */ function au_subgroups_clone_layout($group, $parent) { if (!elgg_is_active_plugin('group_custom_layout') || !group_custom_layout_allow($parent)) { return false; } // get the layout object for the parent if ($parent->countEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION) <= 0) { return false; } $parentlayout = $parent->getEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION); $parentlayout = $parentlayout[0]; $layout = new ElggObject(); $layout->subtype = GROUP_CUSTOM_LAYOUT_SUBTYPE; $layout->owner_guid = $group->getGUID(); $layout->container_guid = $group->getGUID(); $layout->access_id = ACCESS_PUBLIC; $layout->save(); // background image $layout->enable_background = $parentlayout->enable_background; $parentimg = elgg_get_config('dataroot') . 'group_custom_layout/backgrounds/' . $parent->getGUID() . '.jpg'; $groupimg = elgg_get_config('dataroot') . 'group_custom_layout/backgrounds/' . $group->getGUID() . '.jpg'; if (file_exists($parentimg)) { copy($parentimg, $groupimg); } $layout->enable_colors = $parentlayout->enable_colors; $layout->background_color = $parentlayout->background_color; $layout->border_color = $parentlayout->border_color; $layout->title_color = $parentlayout->title_color; $group->addRelationship($layout->getGUID(), GROUP_CUSTOM_LAYOUT_RELATION); }
/** * * @param SilverStripeContentItem $item * @param type $parentObject * @param type $duplicateStrategy * @return TransformResult */ public function transform($item, $parentObject, $duplicateStrategy) { $newFile = $this->getTypeForFile($item->Name); $newFile = new $newFile(); $folderPath = $parentObject->getRelativePath(); $parentId = $parentObject ? $parentObject->ID : 0; $filter = '"ParentID" = \'' . Convert::raw2sql($parentId) . '\' and "Title" = \'' . Convert::raw2sql($item->Name) . '\''; $existing = DataObject::get_one('File', $filter); if ($existing && $duplicateStrategy == ExternalContentTransformer::DS_SKIP) { // just return the existing children return new TransformResult($existing, null); } else { if ($existing && $duplicateStrategy == ExternalContentTransformer::DS_OVERWRITE) { $newFile = $existing; } } $newFile->Name = $item->Name; $newFile->RemoteNodeId = $item->getSS_ID(); $newFile->RemoteSystemId = $item->getSource()->ID; $newFile->Title = $item->Title; $newFile->ParentID = $parentId; $newFile->write(); $filepath = Director::baseFolder() . '/' . $newFile->Filename; Filesystem::makeFolder(dirname($filepath)); $item->streamContent($filepath); return new TransformResult($newFile, null); }