public function process($fh) { // skip und check header $line = trim(fgets($fh)); if ($line != "rating,name,locality,url,country,name_alt,address,lat,lng,postal,address_ext") { $this->logError("Wrong fingerprint \n"); echo $this->getHelp(); Yii::app()->end(); } while (!feof($fh)) { $data = fgetcsv($fh); if ($data !== false) { $rating = $this->parseRating($data[0]); //! Use english for canonical names $name = $data[5] == "" ? $data[1] : $data[5]; //mihan007: just minor thing.. what is 5 and 1? don't like magic numbers. $cityName = $data[2]; $city = City::model()->guess($cityName); if (count($city) == 0) { $this->logError("Problem mapping city " . $data[2]); continue; } $city = $city[0]; $canonicalName = UtilsHelper::canonizeHotelName($name, $city->localEn); $this->saveRow($city->id, $canonicalName, $rating, $name); } } }
public function executeSaveTag() { try { $parameters = $this->getRequest()->getParameterHolder()->getAll(); if ($parameters['id']) { $obj = Document::getDocumentInstance($parameters['id']); $parent = Document::getParentOf($parameters['id']); } else { $obj = new Tag(); $parent = Document::getDocumentInstance($parameters['parent']); } foreach ($parameters as $key => $value) { if (!(strpos($key, 'attr') === false)) { $function = 'set' . str_replace('attr', '', $key); $obj->{$function}($value); } } if (!$parameters['attrExclusive']) { $obj->setExclusive(0); } $obj->save(null, $parent); UtilsHelper::setBackendMsg("Saved"); } catch (Exception $e) { UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error"); } PanelService::redirect('tag'); exit; }
public function validateLogin() { $result = false; if ($login = $this->getRequestParameter('login')) { $password = $this->getRequestParameter('password'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $user = UserPeer::doSelectOne($c); if ($user) { if ($user->getPublicationStatus() != "ACTIVE") { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Not-active", $culture), UtilsHelper::MSG_INFO); } elseif (sha1($user->getSalt() . $password) == $user->getSha1Password()) { $this->getUser()->setAttribute('pass', $password); $this->getUser()->signIn($user); // redirect to dashboard $this->showDashboard(); $result = true; } else { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Wrong-login", $culture), UtilsHelper::MSG_ERROR); } } else { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Wrong-login", $culture), UtilsHelper::MSG_ERROR); } } else { if ($this->getUser()->isAuthenticated()) { // redirect to dashboard $this->showDashboard(); } } }
public function Inserir($params) { $nome = $params['profnome']; $sobrenome = $params['profsobrenome']; $email = $params['profemail']; $cpf = $params['profcpf']; $rg = $params['profrg']; $rg = $params['proftitulacao']; //**** TAREFA DO PROXY **** $msgErro = ""; if ($nome == "" || strlen($nome) <= 2) { $msgErro .= '- O campo "nome" deve ser preenchido<br/>'; } if ($sobrenome == "" || strlen($sobrenome) <= 2) { $msgErro .= '- O campo "nome" deve ser preenchido<br/>'; } if ($email == "") { $msgErro .= '- O campo "e-mail" deve ser preenchido<br/>'; } else { if (strpos($email, '@') <= 3 || strlen($email) == 0) { $msgErro .= '- Informe um e-mail válido<br/>'; } } if ($cpf != "" && strlen($cpf) < 11) { $msgErro .= '- Informe um CPF válido<br/>'; } if ($msgErro != "") { //$msgErro = "Verifique os campos obrigatórios: <br/>".$msgErro; self::SetErro($msgErro); return $this->views . "index.php"; } //Registrar como usuário (enviar e-mail, etc...) $usuario = new UsuarioModel(); $usuario->setEmail($email); $usuario->setIdPermissao(2); $usuario->setLogin($nome); $usuario->setSenha(UtilsHelper::CriarSenhaTemporaria($nome)); $daoUsuario = new DaoUsuario(); if (!$daoUsuario->Inserir($usuario)) { self::SetErro(DaoUsuario::GetErro()); } //Fim do registro de usuário //**** FIM TAREFA DO PROXY **** //TODO Buscar uma maneira de marcar os campos com erro na view (como se pode fazer usando a ViewStade do .Net no Razor) $cpf = (int) $cpf == 0 ? null : $cpf; $rg = (int) $rg == 0 ? null : $rg; $professor = new ProfessorModel(); $professor->setEmail($email); $professor->setNome($nome); $professor->setSobrenome($sobrenome); $professor->setCpf($cpf); $professor->setRg($rg); $res = $this->repositorio->Inserir($professor); if (!$res) { $msg = DaoProfessor::getInstance()->GetErro(); self::SetErro($msg); } return $this->views . "index.php"; }
public function executeValidateEmail() { $myValidator = new sfEmailValidator(); $myValidator->initialize($this->getContext(), array()); $value = urldecode($this->getRequestParameter('value')); if (!$myValidator->execute($value, $error)) { exit(UtilsHelper::Localize('system.frontend.Validate_email_error')); } exit("ok"); }
public function executeList($getFirstgalleries = false) { $this->setLayout(false); $c = new Criteria(); $c->addJoin(GalleryPeer::ID, RelationPeer::ID2, Criteria::LEFT_JOIN); $c->add(GalleryPeer::PUBLICATION_STATUS, UtilsHelper::STATUS_ACTIVE); $c->addAscendingOrderByColumn(RelationPeer::SORT_ORDER); $this->pager = UtilsHelper::pager("Gallery", $c, 10); $this->paging = $this->pager->paging(true); }
public function executeList() { $this->setLayout(false); $c = new Criteria(); // $c->addJoin(NewsPeer::ID, DocumentPeer::ID, Criteria::LEFT_JOIN ); // $c->addJoin(NewsPeer::ID, RelationPeer::ID1 ); // $c->addJoin(NewsI18nPeer::ID, RelationPeer::ID2 ); $c->add(NewsPeer::PUBLICATION_STATUS, UtilsHelper::STATUS_ACTIVE); $c->addDescendingOrderByColumn(NewsPeer::START_DATE); $this->pager = UtilsHelper::pager("News", $c, 15); $this->paging = $this->pager->paging(true); }
public function executeEditBrand() { $this->setLayout(false); $ownersArr = array('' => '--- изберете ---'); $root = Rootfolder::getRootfolderByModule('clients'); $owners = Document::getChildrenOf($root->getId(), 'Client'); foreach ($owners as $ow) { $ownersArr[$ow->getId()] = $ow->getLabel(); } $this->ownersArr = $ownersArr; $this->kindsArr = UtilsHelper::loadTrademarkTypes(); return PanelService::objectEdit('search', 'Brand', $this); }
public function executeSavePage() { try { PanelService::objectSave($obj, $parent); Urlrewrite::updateUrlRelationCache(); //UtilsHelper::setBackendMsg("Saved"); } catch (Exception $e) { UtilsHelper::setBackendMsg("Error saving Page: " . $e->getMessage(), "error"); } // exec('rm -fr '.SF_ROOT_DIR.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'menus/*'); // PanelService::redirect(); // exit(); }
public function executeSaveNewsI18n() { try { BackendService::objectSave($obj, $parent); $end_date = $obj->getEndDate(); $obj->setEndDate(substr($end_date, 0, 11) . '23:59:59'); $obj->save(null, $parent, $parameters["attrCulture"]); UtilsHelper::setBackendMsg("Saved"); } catch (Exception $e) { UtilsHelper::setBackendMsg("Error while saving: " . $e->getMessage(), "error"); } $this->forward(strtolower($this->getRequestParameter('moduleName')), "edit" . $this->getRequestParameter('documentName')); exit; }
public function executeLogin() { $referer = @$_SERVER['HTTP_REFERER']; if (!strstr($referer, 'panel') || !strstr($referer, "?")) { $referer = null; } $this->getUser()->setAttribute('referer', $referer); $this->setLayout("panel"); if ($this->getRequestParameter("submit")) { if ($this->getRequestParameter("login") && $this->getRequestParameter("password")) { $subscriber_pass = $this->getRequestParameter('password'); $subscriber_login = $this->getRequestParameter('login'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $subscriber_login); $subscriber = UserPeer::doSelectOne($c); if ($subscriber) { if ($subscriber->getBackend() != 1) { // $this->getRequest()->setError('login_error', 'Your have no access to site admisnistration'); UtilsHelper::setBackendMsg('Your have no access to site admisnistration', "info"); } elseif ($subscriber->getPublicationStatus() != UtilsHelper::STATUS_ACTIVE) { // $this->getRequest()->setError('login_error', 'Your account is not active'); UtilsHelper::setBackendMsg('Your account is not active', "info"); } elseif (sha1($subscriber->getSalt() . $subscriber_pass) == $subscriber->getSha1Password()) { $this->getUser()->signIn($subscriber); $this->user = $subscriber; //exit("referer ".$_SERVER['HTTP_REFERER']); $this->redirect($this->getUser()->getAttribute("referer")); } else { // $this->getRequest()->setError('login_error', 'Wrong password'); UtilsHelper::setBackendMsg('Wrong username or password', "error"); } } else { UtilsHelper::setBackendMsg('Wrong username or password', "error"); } } else { // $this->getRequest()->setError('login_error', 'Please, enter username and password'); UtilsHelper::setBackendMsg('Please, enter username and password', "info"); } } else { if ($subscriber = $this->getUser()->getAttribute('forceAutoLogAsAdmin')) { $this->getUser()->signIn($subscriber); $this->getUser()->setAttribute('forceAutoLogAsAdmin', null); $this->redirect("http://" . $_SERVER['HTTP_HOST'] . "/admin/index.php?refresh=" . $this->getRequestParameter('refresh')); } } }
public function Inserir($params) { $login = $params['usrlogin']; $email = $params['usremail']; $permissao = $params['usrpermissao']; //**** TAREFA DO PROXY **** $msgErro = ""; if ($login == "") { $msgErro .= '- O campo "login" deve ser preenchido<br/>'; } else { if (strlen($login) <= 5) { $msgErro .= 'O campo "login" deve ter no mínimo 6 caracteres<br/>'; } } if ($email == "") { $msgErro .= '- O campo "e-mail" deve ser preenchido<br/>'; } else { if (strpos($email, '@') <= 3 || strlen($email) == 0) { $msgErro .= '- Informe um e-mail válido<br/>'; } } if ((int) $permissao < 1) { $msgErro .= '- O campo "permissão" deve ser preenchido<br/>'; } if ($msgErro != "") { $msgErro = "Verifique os campos obrigatórios: <br/>" . $msgErro; self::SetErro($msgErro); return $this->views . "index.php"; } //TODO Buscar uma maneira de marcar os campos com erro na view (como se pode fazer usando a ViewStade do .Net no Razor) //**** FIM TAREFA DO PROXY **** $senha = UtilsHelper::CriarSenhaTemporaria(); $usuario = new UsuarioModel(); $usuario->setEmail($email); $usuario->setLogin($login); $usuario->setSenha($senha); $usuario->setIdPermissao($permissao); $res = $this->repositorio->Inserir($usuario); if (!$res) { $msg = DaoUsuario::getInstance()->GetErro(); self::SetErro($msg); } return $this->views . "index.php"; }
public function actionGetInfo($id) { $model = GdsRequest::model()->findByPk(new MongoID($id)); $retArr = array(); $widget = new CTextHighlighter(); $widget->language = 'xml'; $retArr['methodName'] = $model->methodName; $retArr['requestXml'] = $widget->highlight($model->requestXml); if (strlen($model->responseXml) < 7500) { $retArr['responseXml'] = $widget->highlight($model->responseXml); } else { $retArr['responseXml'] = '<pre>' . htmlspecialchars(UtilsHelper::formatXML($model->responseXml)) . '</pre>'; } $retArr['timestamp'] = date("Y-m-d H:i:s", $model->timestamp); $retArr['executionTime'] = Yii::app()->format->formatNumber($model->executionTime); $retArr['errorDescription'] = $model->errorDescription; //$retArr['responseXml'] = $model->responseXml; //echo $model->requestXml); echo json_encode($retArr); die; }
/** * Method to find rating for given hotels in given city * * @param array $hotel_names Names of hotels we want to lookup rating for * @param City $city City model instance for given hotel * @return array HotelName => rating */ public function findByNames($hotel_names, $city) { $canonized_names = array(); foreach ($hotel_names as $name) { $canonical_name = UtilsHelper::canonizeHotelName($name, $city->localEn); $canonized_names[$name] = $canonical_name; } $criteria = new CDbCriteria(); $criteria->addInCondition("canonical_name", $canonized_names); $criteria->addColumnCondition(array("city_id" => $city->id)); $rows = $this->findAll($criteria); $canonical_name_to_rating = array(); foreach ($rows as $row) { $canonical_name_to_rating[$row->canonical_name] = $row->rating; } $name_to_rating = array(); foreach ($canonized_names as $name => $canonical_name) { if (isset($canonical_name_to_rating[$canonical_name])) { $name_to_rating[$name] = $canonical_name_to_rating[$canonical_name]; } } return $name_to_rating; }
RUB.<br> <?php } ?> </div> <img src="images/vertLine.png" class="hr"> <?php } ?> <table class="lastPriceInfo"> <tr> <td class="tdInfo"> </td> <td class="tdPrice"> <div class="finishPriceHotel"> Итоговая стоимость <span class="price"><?php echo UtilsHelper::formatPrice($ticket->getPrice()); ?> </span> RUB<br> <span class="done">Оплачено полностью</span> </div> </td> </tr> </table> </div> <div class="lastWords">Желаем вам ярких эмоций и хорошего отдыха</div> </div> </body> </html>
public function executeSearch() { try { $this->setLayout(false); $request = $this->getRequest(); $params = $request->getParameterHolder()->getAll(); $searchOf = array(); foreach ($params as $key => $param) { $parts = explode("-", $key); if ($parts[0] == "field" && !empty($param)) { str_replace(array('+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\', '.', '/'), array('\\+', '\\-', '\\&&', '\\||', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\"', '\\~', '\\*', '\\?', '\\:', '\\\\', '\\.', '\\/'), $param); $searchOf[$parts[1]] = trim($param); } } /////////////////////// QUERY BUILDING ////////////////////////// $q = new Zend_Search_Lucene_Search_Query_Boolean(); $queryTerms = explode(" ", strtolower($query)); $i = 0; $query = ""; foreach ($searchOf as $field => $term) { if ($i > 0) { $query .= ' AND '; } $query .= $field . ':'; if ($field == "NiceClasses" || $field == "ViennaClasses") { $query .= '('; $parts = explode(",", $term); foreach ($parts as $el) { for ($e = 1; $e < 21; $e++) { $query .= $field . $e . ':"' . trim($el) . '" OR '; } } $query = substr($query, 0, -4) . ")"; } elseif ($field == "DesignatedContractingParty") { $query .= '('; $parts = explode(",", $term); foreach ($parts as $el) { for ($e = 1; $e < 21; $e++) { $query .= $field . $e . ':"' . trim($el) . '" OR '; } } $query = substr($query, 0, -4) . ")"; } elseif ($field == "Label") { if (strpos($term, "*") !== false || strpos($term, "?") !== false) { $query .= trim($term); } else { $query .= trim($term) . '~0.7'; } } else { if (strpos($term, "*") !== false || strpos($term, "?") !== false) { $query .= trim($term); } else { $query .= trim($term); } } $i++; } //echo "QUERY: ".$query; $q = Zend_Search_Lucene_Search_QueryParser::parse($query); //////////////////////// SEARCH EXECUTION //////////////////// $searchIndex = Zend_Search_Lucene::open(sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'search/'); //Zend_Search_Lucene::setResultSetLimit(100); $searchResults = $searchIndex->find($q); //$this->count = count($searchResults); //$this->results = $searchResults; $this->pager = UtilsHelper::pager("Trademark", $searchResults, 100); $this->count = $this->pager->getNbResults(); $this->paging = $this->pager->paging(); } catch (Exception $e) { $this->error = $e->getMessage(); } }
/** * Sorting elements by key (key may be property, array key, or method) */ public static function sortBy(&$sortingArray, $sortByKey, $orderAsc = true, $saveIndexes = false) { // //self::$sortingArray = null; self::$sortKey = $sortByKey; $function_name = ''; self::$orderSort = $orderAsc ? 1 : -1; foreach ($sortingArray as $firstElem) { break; } if (is_array($firstElem)) { $function_name = 'UtilsHelper::compareByKey'; } if (is_object($firstElem)) { if (method_exists($firstElem, $sortByKey)) { $function_name = 'UtilsHelper::compareByMethod'; } else { $function_name = 'UtilsHelper::compareByProperty'; } } if ($saveIndexes) { uasort($sortingArray, $function_name); } else { usort($sortingArray, $function_name); } }
public function validateChangePassword() { $result = false; if ($activation_code = $this->getRequestParameter('q')) { if ($this->getRequestParameter('password1') && $this->getRequestParameter('password2')) { $password1 = $this->getRequestParameter('password1'); $password2 = $this->getRequestParameter('password2'); if ($password1 == $password2) { $c = new Criteria(); $c->add(UserPeer::ACTIVATION_CODE, $activation_code); $c->add(UserPeer::ACTIVATION_CODE, "{$activation_code}", Criteria::LIKE); $user = UserPeer::doSelectOne($c); if ($user) { $user->setPassword($password2); $user->setActivationCode(''); $user->save(); return true; } else { UtilsHelper::setFlashMsg("Invalid user. Please contact with system administrator", UtilsHelper::MSG_ERROR); } } else { UtilsHelper::setFlashMsg("Passwords doesn't match.", UtilsHelper::MSG_ERROR); } } } return $result; }
function run_generate_cache($task, $args) { ini_set("memory_limit", "2048M"); ini_set("display_errors", 1); define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', false); sfConfig::set("sf_use_relations_cache", false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); run_url_relations($task, $args); run_tags_relations($task, $args); echo_cms_title("GENERATING CACHE..."); if (!class_exists("XMLParser")) { include sfConfig::get('sf_root_dir') . "/lib/tools/XMLParser.class.php"; } if (!class_exists("FileHelper")) { include sfConfig::get('sf_root_dir') . "/lib/helper/FileHelper.php"; } //echo_cms_sep(); echo_cms("sf_cache_objects = " . sfConfig::get('sf_cache_objects')); echo_cms("sf_cache_relations = " . sfConfig::get('sf_cache_relations')); echo_cms("sf_cache_trees = " . sfConfig::get('sf_cache_trees')); //echo_cms_sep(); if (count($args) > 0) { $relationsFlag = substr($args[0], 0, 3) == "rel"; $listsFlag = substr($args[0], 0, 4) == "list"; $cacheModel = $args[0]; if (is_numeric($cacheModel)) { $obj = Document::getDocumentInstance($cacheModel); if ($obj) { $phpName = get_class($obj); } else { echo_cms_error("Object with ID=" . $cacheModel . " not found!"); exit; } } } // parse schema file to make Schema.class.php $objects = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/config/schema.xml"); $schemaFile = sfConfig::get('sf_root_dir') . "/config/Schema.class.php"; $content = $content = "<?php\n class Schema\n{\n\n"; echo_cms("Building " . $schemaFile . "... "); foreach ($objects as $obj) { if ($obj['tag'] == 'TABLE' && $obj['type'] == 'open') { $table = $obj['attributes']['PHPNAME']; if ($phpName && $phpName == $table) { $tableName = $obj['attributes']['NAME']; } $trees = explode(",", $obj['attributes']['TREE']); $content .= "\tpublic static function get" . $table . "Trees()\n\t{\n"; $content .= "\t\treturn array("; foreach ($trees as $tree) { $content .= "'" . strtolower($tree) . "', "; } $content = substr($content, 0, -2); $content .= ");\n\t}\n\n"; $content .= "\tpublic static function get" . $table . "Properties()\n\t{\n"; $content .= "\t\treturn array("; } if ($obj['tag'] == 'COLUMN' && $obj['type'] == 'complete') { $property = $obj['attributes']['NAME']; $getProperty = UtilsHelper::convertFieldName($property); $content .= "'" . $getProperty . "', "; } if ($obj['tag'] == 'TABLE' && $obj['type'] == 'close') { $content = substr($content, 0, -2); $content .= ");\n\t}\n\n"; } } $content .= "\n}"; //echo_cms_sep(); if (FileHelper::writeFile($schemaFile, $content)) { echo_cms($schemaFile . " writen successfully!"); } else { echo_cms_error("Error writing " . $schemaFile . "!"); } echo "\n"; //echo_cms_sep(); if (substr($args[0], 0, 5) == "schema") { echo_cms(" Done!"); exit; } if (!$relationsFlag && !$listsFlag) { try { if (is_numeric($cacheModel)) { $obj = array(); $obj['tag'] = 'OBJECT'; $obj['type'] = 'complete'; $obj['id'] = $cacheModel; $objects = array($obj); $exit = true; } elseif ($cacheModel) { $obj = array(); $obj['tag'] = 'OBJECT'; $obj['type'] = 'complete'; $obj['value'] = $cacheModel; $objects = array($obj); $exit = true; } else { $objects = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/config/cachedObjects.xml"); } foreach ($objects as $obj) { if ($obj['tag'] == 'OBJECT' && $obj['type'] == 'complete') { if ($id = $obj['id']) { $obj = Document::getDocumentInstance($id); $model = get_class($obj); $c = new Criteria(); $c->add($tableName . '.ID', $id); } else { $model = $obj['value']; $c = new Criteria(); } $classPeer = ucfirst($model) . "Peer"; //$c = new Criteria(); //$results = call_user_func(array($classPeer, 'doSelect'), $c); $peerMethod = "doSelect"; $results = call_user_func(array($classPeer, $peerMethod), $c); echo_cms(" Caching " . $model . " documents"); $ind = 0; foreach ($results as $result) { if ($ind % 20 == 0) { echo $ind . " .\r"; } else { if ($ind % 10 == 0) { echo $ind . " o\r"; } } $ind++; Document::cacheObj($result, $model, false); } echo_cms(" ====> " . $ind . " " . $model . " Document(s) cached."); //echo_cms_sep(); } } if ($exit) { exit; } } catch (Expection $e) { echo_cms_error(" Error: {$e}"); } } if (!$listsFlag) { echo "\n"; //echo_cms_sep(); echo_cms("Writing relations cache"); Relation::checkRelationCache('lock'); try { $c = new Criteria(); $c->addAscendingOrderByColumn('id1'); $c->addAscendingOrderByColumn('document_model2'); $c->addAscendingOrderByColumn('sort_order'); $relations = RelationPeer::doSelect($c); $relationsFile = sfConfig::get('sf_root_dir') . "/cache/objcache/childrenRelations.php"; echo_cms("Processing children :"); $i = 0; $content = "<?php \n"; $oldIDModel = ''; $currIDModel = ''; $idStr = ''; foreach ($relations as $relation) { $currIDModel = $relation->getId1() . ':' . $relation->getDocumentModel2(); if ($i == 0) { $oldIDModel = $currIDModel; } $i++; echo $i . "\t\t\r"; if ($currIDModel == $oldIDModel) { $idStr .= "," . $relation->getId2(); } else { $idStr = substr($idStr, 1); $content .= "\$_Rel[" . $oldId1 . "][\"" . $oldModel2 . "\"] = explode(\",\", \"" . $idStr . "\");\n"; $idStr = "," . $relation->getId2(); } $oldIDModel = $currIDModel; $oldId1 = $relation->getId1(); $oldModel2 = $relation->getDocumentModel2(); } if ($idStr) { $idStr = substr($idStr, 1); $content .= "\$_Rel[" . $oldId1 . "][\"" . $oldModel2 . "\"] = explode(\",\", \"" . $idStr . "\");\n"; } echo "\n"; $content .= "\n?>"; //echo_cms_sep(); if (FileHelper::writeFile($relationsFile, $content)) { echo_cms($relationsFile . " written successfully"); } else { echo_cms_error("Error writing " . $relationsFile . " !"); } //echo_cms_sep(); } catch (Exception $e) { echo "Error: " . $e->getMessage(); } Relation::checkRelationCache('unlock'); } if (!$relationsFlag) { echo "\n"; //echo_cms_sep(); echo_cms_title("Writing Lists cache"); $listsRootFolder = Rootfolder::getRootfolderByModule("lists"); if ($listsRootFolder) { $lists = Document::getChildrenOf($listsRootFolder->getId(), "Lists"); } foreach ($lists as $list) { $listId = $list->getListId(); echo "\t\tprocessing \"" . $listId . "\" list ..."; $listPath = sfConfig::get('sf_root_dir') . "/cache/listscache/" . $listId . ".php"; @unlink($listPath); $content = "<?php \n"; $content .= "\$listItemsForSelect = array(\n"; $items = Lists::getListitemsForSelect($listId, array(), false); foreach ($items as $key => $item) { $content .= "\"" . str_replace("\"", "\\\"", $key) . "\" => \"" . str_replace("\"", "\\\"", $item) . "\",\n"; } $content .= ");\n?>"; if (FileHelper::writeFile($listPath, $content)) { echo_cms(" Done!"); } else { echo_cms_error(" Error!"); } } //echo_cms_sep(); } sfConfig::set("sf_use_relations_cache", true); }
public function executeSaveMedia() { try { $media = Media::upload('attrFilename'); if ($media && $media->IsImage()) { list($originalWidth, $originalHeight) = getimagesize($media->getServerAbsoluteUrl()); if ($originalWidth > $originalHeight && $originalWidth > 1500) { $media->resizeImage(null, null, 1500); } else { if ($originalHeight > 1500) { $media->resizeImage(null, 1500); } } $media->resizeImage("thumbs", 100); } else { if ($media && in_array($media->getFiletype(), array("video/x-msvideo", "video/mpeg", "video/mp4", "video/quicktime", "video/x-ms-wmv", "video/avi", "video/wmv"))) { $media->convertToFlv(); } else { if ($media && in_array($media->getFiletype(), array("video/x-flv", "flv-application/octet-stream"))) { $media->saveFlv(); } else { if ($media && in_array($media->getFiletype(), array("application/octet-stream")) && substr($media->getFilename(), -4) == ".flv") { $media->saveFlv(); } else { if ($media && in_array($media->getFiletype(), array("application/binary")) && substr($media->getFilename(), -4) == ".mpg" || $media && in_array($media->getFiletype(), array("application/binary")) && substr($media->getFilename(), -5) == ".mpeg") { $media->convertToFlv(); } } } } } UtilsHelper::setBackendMsg("Saved"); } catch (Exception $e) { UtilsHelper::setBackendMsg("Error while saving: " . UtilsHelper::Localize("media.backend." . $e->getMessage(), "en"), "error"); } $this->forward(strtolower($this->getRequestParameter('moduleName')), "edit" . $this->getRequestParameter('documentName')); }
<div class="right-box no-border"> <h3 class="right-heading"><span class="cats"><?php echo UtilsHelper::Localize("website.frontend.Products_menu_title"); ?> </span></h3> <ul class="cat-nav"> <?php foreach ($categories as $cat) { $id = $cat->getId(); ?> <li> <a href="<?php echo UtilsHelper::cleanRssURL($cat); ?> " title="" <?php if ($id == $currentId) { ?> class="active"<?php } ?> > <?php echo $cat->getLabel(); ?> <span>(<?php echo $prodNum[$id]; ?> )</span> </a> </li> <?php
<!--<h1 id="lead" class="lead serif-italic"><?php echo UtilsHelper::Localize("website.frontend.News-title"); ?> </h1>--> <?php $count = $pager->getNbResults(); foreach ($pager->getResults() as $n) { $url = UtilsHelper::cleanURL($n); ?> <div class="news" style="float: left; width: 190px;"> <h3><?php echo $n->getLabel(); ?> </h3> <?php echo UtilsHelper::Date($n->getStartDate(), "m.d.Y"); ?> <br /> <?php echo $n->getShortDescription(); ?> <?php if ($n->getImage() != NULL) { ?> <br /> <img src="/media/upload/thumbs/<?php echo $n->getImage(); ?> " /> <?php }
} ?> </p> <?php php; ?> </div> </div> </div> <div class="qfRepImpSsCol qfRepImpSsRight"> <?php foreach ($searchOf as $f) { ?> <p><?php echo UtilsHelper::Localize(strtolower($f)); ?> </p> <?php } ?> </div> </div> <?php } ?> <!--<a href="import-session-highlight.php"> <div class="qfRepImpSsItem"> <div class="qfRepImpSsCol qfRepImpSsLeft"> <div class="qfRepImpSsColInn">
<div class="row"> <div class="grid_1 right"><strong id="sub_total">$<?php echo $sub_total; ?> </strong></div><div class="grid_2 right">Merchandise Total:</div> <div class="clear"></div> <div class="grid_1 right"><strong id="taxes_total">$<?php echo $total_taxes; ?> </strong></div><div class="grid_2 right">Estimated Taxes:</div> <div class="clear"></div> <div class="grid_1 right"><strong id="total">$<?php echo $total; ?> </strong></div><div class="grid_2 right">Total:</div> <div class="clear"></div> </div> <br /> <p class="extra"></p> </div> <p><?php echo UtilsHelper::Localize("website.frontend.checkout_text"); ?> </p> <p class="no-border"><a class="button-cont" title="#" href="<?php echo $processPageUrl; ?> "><span>Check out</span></a></p> <div class="clear"></div> </div>
public function paging($panel = false, $cnt = 5) { $totalPages = $this->getLastPage(); $currPage = $this->getPage(); $startPages = floor(($currPage - 1) / $cnt) * $cnt + 1; $endPages = $startPages + $cnt - 1; $nextPages = $endPages + 1; if ($endPages > $totalPages) { $endPages = $totalPages; } $prevPages = $startPages - 1; $html = ""; if ($totalPages > 1) { if ($panel) { $html = "<ul class='paginationControl'>"; } if ($startPages != 1) { if ($panel) { $html .= "<li>"; } $html .= '<a title="first" class="first" href="' . UtilsHelper::keepUrl('page=1') . '">first</a>'; if ($panel) { $html .= "</li>"; } if ($panel) { $html .= "<li>"; } $html .= '<a title="previous" class="prev" href="' . UtilsHelper::keepUrl('page=' . $prevPages) . '">previous</a>'; if ($panel) { $html .= "</li>"; } } for ($p = $startPages; $p <= $endPages; $p++) { $pg = $p; /*if ($p < 10) { $pg = '0'.$pg; }*/ if ($p == $currPage) { if ($panel) { $html .= "<li class='selected'>"; } $html .= '<a title="page ' . $p . '" class="active" href="#">' . $pg . '</a>'; if ($panel) { $html .= "</li>"; } } else { if ($panel) { $html .= "<li>"; } $html .= '<a title="page ' . $p . '" href="' . UtilsHelper::keepUrl('page=' . $p) . '">' . $pg . '</a>'; if ($panel) { $html .= "</li>"; } } /*if ($p < $endPages) { $html .= ' | '; }*/ } if ($totalPages >= $nextPages) { if ($panel) { $html .= "<li>"; } $html .= '<a title="next" class="next" href="' . UtilsHelper::keepUrl('page=' . $nextPages) . '">next</a>'; if ($panel) { $html .= "</li>"; } if ($panel) { $html .= "<li>"; } $html .= '<a title="last" class="last" href="' . UtilsHelper::keepUrl('page=' . $totalPages) . '">last (' . $totalPages . ')</a>'; if ($panel) { $html .= "</li>"; } } if ($panel) { $html .= "</ul>"; } } return $html; }
public static function makeBlock($itemsArr, $label, $paramStr) { $str = '<td width="20%" valign="top" height="100%"> <table cellspacing="0" cellpadding="0" border="0" class="top_ten_location"> <tr> <td valign="top"> <h2 class="top_ten_title">' . UtilsHelper::Localize('properties.frontend.' . $label) . '</h2> <ul class="top_ten_list"> '; foreach ($itemsArr as $item) { $str .= ' <li><a title="' . $item['label'] . ' (' . $item['count'] . ') " href="' . $listUrl . '?' . $paramStr . '=' . $item['id'] . '">' . $item['label'] . ' (' . $item['count'] . ')</a></li> '; } $str .= ' </ul> </td> </tr> </table> </td>'; return $str; }
public function executeUploadBanners() { $this->setLayout("backend"); $c = new Criteria(); $c->add(PrefPeer::LABEL, "newsletter"); $info = PrefPeer::doSelectOne($c); if (!$info) { $info = new Pref(); $info->setLabel("newsletter"); $info->save(); } if ($this->getRequestParameter('submitted')) { $request = $this->getRequest(); try { $request->setParameter('parent', $info->getId()); if ($request->getFileName('banner1')) { $request->setParameter('id', $this->getRequestParameter('banner1Id')); $request->setParameter('attrLabel', 'newsletter468x60'); $media = Media::upload('banner1', "upload/newsletter", array("image/gif", "image/png", "image/jpeg", "image/pjpeg", "image/x-png")); if ($media && $media->IsImage()) { $media->resizeImage(null, 60, 468); $media->resizeImage("thumbs", 30, 231); } } if (!$media) { $media = Document::getDocumentInstance($this->getRequestParameter('banner1Id')); } if ($media) { $media->setDescription($this->getRequestParameter('banner1Url')); $media->save(); } if ($request->getFileName('banner2')) { $request->setParameter('id', $this->getRequestParameter('banner2Id')); $request->setParameter('attrLabel', 'newsletter160x600'); $media2 = Media::upload('banner2', "upload/newsletter", array("image/gif", "image/png", "image/jpeg", "image/pjpeg", "image/x-png")); if ($media2 && $media2->IsImage()) { $media2->resizeImage(null, 600, 160); $media2->resizeImage("thumbs", 125, 40); } } if (!$media2) { $media2 = Document::getDocumentInstance($this->getRequestParameter('banner2Id')); } if ($media2) { $media2->setDescription($this->getRequestParameter('banner2Url')); $media2->save(); } $infoVal = $this->getRequestParameter('info'); if (!$infoVal) { $infoVal = null; } $info->setContent($infoVal); $info->save(); } catch (Exception $e) { $this->message = UtilsHelper::Localize("media.backend." . $e->getMessage()); } } $c = new Criteria(); $c->add(PrefPeer::LABEL, "newsletter"); $this->info = PrefPeer::doSelectOne($c); $c = new Criteria(); $c->add(MediaPeer::LABEL, "newsletter468x60"); $this->banner1 = MediaPeer::doSelectOne($c); $c = new Criteria(); $c->add(MediaPeer::LABEL, "newsletter160x600"); $this->banner2 = MediaPeer::doSelectOne($c); }
?> <label for="name2">Регистров номер: </label> <?php echo frontend_input("field-RegisterNumber"); ?> <label for="name3">Дата на заявяване: </label> <?php echo frontend_input("field-ApplicationDate", null, array("readonly" => "readonly")); ?> <label for="name3">Тип: </label> <?php echo frontend_select("field-Kind", null, UtilsHelper::loadTrademarkTypes(array("" => "Моля изберете"))); ?> </div> <div class="qfTwoCol qfTwoCol02"> <label for="name4">Срок: </label> <?php echo frontend_input("field-ExpiresOn"); ?> <label for="name5">Държави в които е в сила: </label> <?php echo frontend_select("field-DesignatedContractingParty", null, array("" => "Моля изберете") + $countries); ?>
<?php $count = $pager->getNbResults(); foreach ($pager->getResults() as $n) { $url = UtilsHelper::cleanURL($n); ?> <div class="news"> <h2><?php echo $n->getLabel(); ?> </h2> <?php echo UtilsHelper::Date($n->getStartDate(), "H:i | d.m.Y"); ?> | Прочетена: <strong><?php echo $n->getRds(); ?> пъти</strong> <?php $img = $n->getImage(); if ($image = Document::getDocumentInstance($img)) { ?> <img width="528" src="/media/upload/<?php echo $img; ?> " class="news_im" title="<?php echo $image->getDescription(); ?> "/> <?php } ?>
<li class="ui-state-default" id="<?php echo $class . '_' . $id; ?> "> <div class="row"> <div class="col-aa"><input type="checkbox" name="check"></div> <div class="col-aa" ><img src="/images/icons/<?php echo strtolower($class); ?> .png" align="top"></div> <div class="col-a"> <a <?php echo $href; ?> ><?php echo UtilsHelper::cutStr($label, 80, '...'); ?> </a> </div> <div class="col-f"> <?php if (isset($user_rights[$module][$class]) && isset($user_rights[$module][$class]['delete'])) { ?> <a href="javascript:void(0);" title="Delete" class="del"></a> <?php } else { ?> <a href="javascript:void(0);" onclick="return noDelete();" title="Delete" class="nodel"></a> <?php } ?>