public function executeGalleryPicsList() { $parentId = $this->getRequestParameter("parentMediaId"); $code = ''; if ($deleteId = $this->getRequestParameter("deleteId")) { if ($delObj = Document::getDocumentInstance($deleteId)) { $delObj->delete(); } } $children = Document::getChildrenOf($parentId, "Media"); $res = ' <ul id="images-grid" class="ui-sortable"> ###images### </ul> <div class="clear"></div> '; foreach ($children as $pic) { $code .= ' <li id="image_' . $pic->getId() . '" class="ui-state-default"> <img src="' . $pic->getRelativeThumbUrl() . '" title="' . $pic->getDescription() . '"> <div class="image-options"> <!--a class="image-zoom" href="javascript:void(0);"></a--> <a class="image-edit" href="javascript:void(0);"></a> <a class="image-delete" href="javascript:void(0);"></a> </div> </li> '; } if ($code) { exit(str_replace('###images###', $code, $res)); } else { exit($code); } }
public function executePageGallery() { $this->setLayout(false); $id = $this->getRequestParameter('pageref'); if ($page = Document::getDocumentInstance($id)) { $this->images = Document::getChildrenOf($id, "Media"); //$this->galleryLabel = $page->getGalleryLabel(); } }
public function executeDetail() { $this->setLayout(false); if ($id = $this->getRequestParameter('News_id')) { if ($this->news = Document::getDocumentInstance($id)) { //$reads = $this->news->getRds()+1; //$this->news->setRds($reads); //$this->news->save(); $this->images = Document::getChildrenOf($id, 'Media', false); } } }
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 executeGalleryPicsList() { $parentId = $this->getRequestParameter("parentMediaId"); $type = $this->getRequestParameter("gallery_type"); $code = ''; if ($type == 1) { if ($I18n = Document::getDocumentByCulture($parentId, null, true)) { $parentId = $I18n->getId(); } else { exit($code); } } if ($deleteId = $this->getRequestParameter("deleteId")) { if ($delObj = Document::getDocumentInstance($deleteId)) { $delObj->delete(); } } $children = Document::getChildrenOf($parentId, "Media"); if ($type == 1) { // var_dump($children); $res = ' <ul id="images-grid" class="ui-sortable"> ###images### </ul> <div class="clear"></div> '; foreach ($children as $pic) { $code .= ' <li id="image_' . $pic->getId() . '" class="ui-state-default"> <img src="' . $pic->getRelativeThumbUrl() . '"> <div class="image-options"> <!--<a class="image-zoom" href="javascript:void(0);"></a> <a class="image-edit" href="javascript:void(0);"></a>--> <a class="image-delete" href="javascript:void(0);"></a> </div> </li> '; } if ($code) { exit(str_replace('###images###', $code, $res)); } else { exit($code); } } else { $code = ""; foreach ($children as $pic) { $code .= "<li><img src='" . $pic->getRelativeThumbUrl() . "'><img onclick='deleteGalleryMedia(" . $parentId . ", " . $pic->getId() . ");' src='/images/icons/delete.png'/></li>"; } } exit($code); }
public function executeMainNav() { $this->setLayout(false); $menuItems = array(); if ($menu = Document::getDocumentByExclusiveTag("website_menu_main")) { $topics = Document::getChildrenOf($menu->getId(), 'Topic'); foreach ($topics as $t) { $pages = Document::getChildrenOf($t->getId(), 'Page'); foreach ($pages as $p) { if (Document::hasTag($p, 'website_page_index')) { $menuItems[$t->getId()] = $p; break; } } } } $this->menuItems = $menuItems; }
function run_dm($task, $args) { ini_set("memory_limit", "6146M"); ini_set("display_errors", 1); define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); sfConfig::set('sf_cache_objects', false); sfConfig::set('sf_cache_relations', false); sfConfig::set('sf_use_relations_cache', false); $c = new Criteria(); //$c->add(ImportSessionPeer::CREATED_AT, "2014-10-12", Criteria::GREATER_THAN); //$c->add(ImportSessionPeer::IMPORT_ID, null, Criteria::ISNOTNULL); $c->addJoin(ImportSessionPeer::IMPORT_ID, ImportPeer::ID, Criteria::LEFT_JOIN); $c->add(ImportPeer::SYSTEM, 3); $c->add(ImportSessionPeer::CREATED_AT, "2014-11-21", Criteria::GREATER_EQUAL); $importSessions = ImportSessionPeer::doSelect($c); $i = 1; foreach ($importSessions as $importSession) { $res = Document::getChildrenOf($importSession->getId(), "SearchMatch"); foreach ($res as $r) { $r->delete(); echo "."; } $importSession->delete(); echo "+"; $search_index_path = SF_ROOT_DIR . '/cache/search/' . $importSession->getId(); echo "DELETING " . $search_index_path . "\n"; exec("rm -fr {$search_index_path}"); echo $i . "\n"; $i++; } sfConfig::set('sf_cache_objects', true); sfConfig::set('sf_cache_relations', true); sfConfig::set('sf_use_relations_cache', true); exit("\n"); }
public function executeAccountCreate() { $this->setLayout(false); //assign vars $folder = Document::getDocumentByExclusiveTag("categories_folder_" . SECTION); if ($folder) { $cats = Document::getChildrenOf($folder->getId(), "Category"); foreach ($cats as $cat) { $categories[$cat->getId()] = $cat->getlabel(); } } $first = array(0 => "all categories"); $categories = $first + $categories; $this->categories = $categories; if ($this->media) { $this->cv = $this->media; } elseif ($this->user && $this->type == "user") { $cv_id = $this->user->getCv(); $cv = Document::getDocumentInstance($cv_id); $this->cv = $cv; $accpage = Document::getDocumentByExclusiveTag("website_page_account"); if ($accpage) { $this->accountPageUrl = $accpage->getHref(false); } } if ($this->media) { $this->logo = $this->media; } elseif ($this->user && $this->type == "company") { $logo_id = $this->company->getLogo(); $logo = Document::getDocumentInstance($logo_id); $this->logo = $logo; $accpage = Document::getDocumentByExclusiveTag("website_page_account"); if ($accpage) { $this->accountPageUrl = $accpage->getHref(false); } } if ($this->getRequestParameter('submitted') == "submitted") { $new = false; $search = array(",", "/", "\\", "[", "]", "?", "!", "@", "#", "\$", "~", "&", "'", '"', "=", "-", ":", ";", "*", "%", "+", "(", ")", "{", "}", "|", "§", "<", ">", "_", "“", "�?", "„", "`"); $replace = array("", "", "", "", "", "", "", "", "", "", "", "", " ", " ", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); $params = $this->getRequest()->getParameterHolder()->getAll(); foreach ($params as $key => $param) { if (!is_array($param)) { ${$key} = trim($param); } else { ${$key} = $param; } } if ($this->user) { if ($this->user->getLogin() == "admin") { UtilsHelper::setFlashMsg("Admin account cannot be edited in frontend"); $this->noform = true; return "Success"; } UtilsHelper::setFlashMsg("Your profile has been successfully updated", UtilsHelper::MSG_SUCCESS); } else { $new = true; $code = md5(time()); $this->user = new User(); $this->user->setBackend(0); // MAKE SURE NO ACCESS TO ADMIN IS ALLOWED $this->user->setActivationCode($code); } if ($this->type == "company") { $this->user->setFirstname($firstname); $this->user->setLastname($lastname); $this->user->setEmail($email); $this->user->setPhone($phone); if (!empty($password)) { $this->user->setPassword($password); } } ////////// GET SAVE FOLDERS ////////////// $userFolders = array(); $mediaFolders = array(); $alphaFolder = false; $mediaAlphaFolder = false; $rootfolderUser = Rootfolder::getRootfolderByModule('user'); $rootfolderMedia = Rootfolder::getRootfolderByModule('media'); if ($rootfolderUser) { $folders = Document::getChildrenOf($rootfolderUser->getId(), 'Folder'); } if ($rootfolderMedia) { $foldersMedia = Document::getChildrenOf($rootfolderMedia->getId(), 'Folder'); } foreach ($folders as $folder) { $userFolders[$folder->getLabel()] = $folder->getId(); } foreach ($foldersMedia as $folder) { $mediaFolders[$folder->getLabel()] = $folder->getId(); } $title = @str_replace($search, $replace, $firstname); $title = trim(@str_replace(' ', ' ', $title)); $title = mb_strtoupper($title); $firstLetter = mb_substr($title, 0, 1); if (array_key_exists($firstLetter, $userFolders)) { $alphaFolder = Document::getDocumentInstance($userFolders[$firstLetter]); } if (array_key_exists($firstLetter, $mediaFolders)) { $mediaAlphaFolder = Document::getDocumentInstance($mediaFolders[$firstLetter]); } if (!$alphaFolder) { $alphaFolder = new Folder(); $alphaFolder->setLabel($firstLetter); $alphaFolder->save(null, $rootfolderUser); } if (!$mediaAlphaFolder) { $mediaAlphaFolder = new Folder(); $mediaAlphaFolder->setLabel($firstLetter); $mediaAlphaFolder->save(null, $rootfolderMedia); } //////////////////////////////////////// if ($this->type == "user") { if ($this->media) { $this->user->setCv($this->media->getId()); } $this->user->setEducation($education); $jobtypes = ""; foreach ($job_types as $jt) { $jobtypes .= "|"; $jobtypes .= $jt; } $this->user->setJobType($jobtypes); $saved = $this->user->save(null, $alphaFolder); } elseif ($this->type == "company") { if (!$this->company) { $this->company = new Company(); } $company_folder = Document::getDocumentByExclusiveTag("company_folder_" . $accountType); $this->company->setLabel($label); $this->company->setAccountType($accountType); $this->company->setDescription($description); $this->company->setCountry($country); $this->company->setCity($city); $this->company->setAddress($address); $this->company->setZip($xip); $this->company->setWeb($web); if ($this->media) { $this->company->setLogo($this->media->getId()); } if ($company_folder) { $this->company->save(null, $company_folder); } else { $this->company->save(); } $saved = $this->user->save(null, $this->company); } if ($this->media) { $this->media->save(null, $mediaAlphaFolder); } if ($saved) { if ($new) { $this->user->setPublicationStatus(UtilsHelper::STATUS_WAITING); $confirmMailPage = Document::getDocumentByExclusiveTag('website_page_confirm'); if ($confirmMailPage) { $data = array(); $data["user"] = $this->user; $data["password"] = $password; $data["comfirmUrl"] = $confirmMailPage->getHref(); $data["code"] = $code; $this->getUser()->setAttribute('registrationData', $data); $body = $this->getPresentationFor("user", "registrationMail"); try { UtilsHelper::sendEmail($email, $body, "Thank you for registering with Us"); UtilsHelper::setFlashMsg("Please check your email to confirm your registration", UtilsHelper::MSG_SUCCESS); $this->noform = true; } catch (Exception $e) { UtilsHelper::setFlashMsg("There was a problem while registering our account, please try again"); if ($this->user) { $this->user->delete(); } if ($this->company) { $this->company->delete(); } if ($this->media) { $this->media->delete(); } } } } } } }
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 executeAddNewTrademark() { $this->setLayout(false); $this->trademarkTypes = UtilsHelper::loadTrademarkTypes(); if ($trademark = Document::getDocumentInstance($this->getRequestParameter('trademark_id'))) { if (get_class($trademark) != 'Trademark') { $trademark = null; } } if (!$trademark) { $trademark = new Trademark(); } $ownersArr = array(); $root = Rootfolder::getRootfolderByModule('clients'); $owners = Document::getChildrenOf($root->getId(), 'Client'); foreach ($owners as $ow) { $ownersArr[$ow->getId()] = $ow->getLabel(); } $this->ownersArr = $ownersArr; $success = false; if ($this->getRequestParameter('submit') > '') { // check input data $request = $this->getRequest(); $params = $request->getParameterHolder()->getAll(); //var_dump($params); $errors = false; $fields = array("label" => 'Наименование', "application_number" => 'Заявка номер', "kind" => 'Тип', "application_date" => 'Дата на заявяване', "expires_on" => 'Срок', "contestation" => 'Краен срок за опозиция', "nice_classes" => 'Класове по Ницска класификация', "rights_owner" => 'Притежател', "office_of_origin" => 'Държава на регистрация', "designated_contracting_party" => 'Държави в които е в сила'); foreach ($fields as $fl => $label) { $val = trim($params[$fl]); if ($val == '') { if ($fl == 'rights_owner') { if ($params['owner'] == '') { $errors = true; $request->setError('err' . $fl, '- ' . $label); } } else { $errors = true; $request->setError('err' . $fl, '- ' . $label); } } } $image = null; if ($errors) { UtilsHelper::setFlashMsg('Моля, въведете необходимите данни:<br>', UtilsHelper::MSG_ERROR); } else { if ($request->getFileName('image')) { try { $image = Media::upload('image', 'upload', array('image/gif', 'image/jpeg', 'image/jpg', 'image/png')); //var_dump($image); list($w, $h) = getimagesize($image->getServerAbsoluteUrl()); if ($w > $h) { $image->resizeImage("thumbs", null, 105); } else { $image->resizeImage("thumbs", 95); } } catch (Exception $e) { $errors = true; $request->setError('errImage', '- ' . UtilsHelper::Localize('media.' . $e->getMessage())); } } if ($errors) { // remove uploaded image if ($image) { $image->delete(); } UtilsHelper::setFlashMsg('Моля, коригирайте:<br>', UtilsHelper::MSG_ERROR); } } // if everithing is OK if (!$errors) { //$trademark = new Brand(); $trademark->setLabel($params['label']); $trademark->setFromSystem(1); if ($params['owner'] > '') { //$trademark->setClientId($params['owner']); $client = Document::getDocumentInstance($params['owner']); $trademark->setRightsOwner($client->getLabel()); } else { $val = trim($params['rights_owner']); $client = new Client(); $client->setLabel($val); $client->save(); //$trademark->setClientId($client->getId()); $this->client = $client; $trademark->setRightsOwner($val); } $trademark->setApplicationNumber($params['application_number']); $trademark->setRegisterNumber($params['register_number']); if ($params['registration_date']) { $trademark->setRegistrationDate($params['registration_date']); } $trademark->setKind($params['kind']); $trademark->setApplicationDate($params['application_date']); $trademark->setStatus($params['status']); $trademark->setExpiresOn($params['expires_on']); $trademark->setContestation($params['contestation']); $trademark->setPublications($params['publications']); $trademark->setViennaClasses(str_replace(' ', '', $params['vienna_classes'])); $trademark->setColors($params['colors']); $trademark->setNiceClasses(str_replace(' ', '', $params['nice_classes'])); $trademark->setRightsOwnerAddress($params['rights_owner_address']); $trademark->setRightsRepresentative($params['rights_representative']); $trademark->setRightsRepresentativeAddress($params['rights_representative_address']); $trademark->setOfficeOfOrigin($params['office_of_origin']); $trademark->setDesignatedContractingParty($params['designated_contracting_party']); if ($image) { $trademark->setImage($image->getId()); } $trademark->save(); $success = true; } } $this->trademark = $trademark; $this->success = $success; }
public function executeAddSearchTemplate() { $this->setLayout(false); $root = Rootfolder::getRootfolderByModule('search'); $brands = Document::getChildrenOf($root->getId(), 'Brand'); foreach ($brands as $b) { $brandsArr[$b->getId()] = $b->getLabel(); } $this->brands = $brandsArr; $success = false; if ($objId = $this->getRequestParameter('obj_id')) { $search = Document::getDocumentInstance($objId); //var_dump($search); } else { $search = new Search(); } if ($this->getRequestParameter('submit') > '') { // check input data $request = $this->getRequest(); $params = $request->getParameterHolder()->getAll(); //var_dump($params); $brandId = $params['brand']; $brand = Document::getDocumentInstance($brandId); //var_dump($brand); $fields = array('label', 'application_number', 'register_number', 'registration_date', 'application_date', 'expires_on', 'vienna_classes', 'nice_classes', 'rights_owner', 'rights_representative', 'office_of_origin', 'designated_contracting_party'); /* $search->setLabel($params['label']); $search->setRightsOwner($params['rights_owner']); $search->setApplicationNumber($params['application_number']); $search->setRegisterNumber($params['register_number']); $search->setRegistrationDate ($params['registration_date']); $search->setApplicationDate($params['application_date']); $search->setStatus($params['status']); $search->setExpiresOn($params['expires_on']); $search->setViennaClasses($params['vienna_classes']); $search->setNiceClasses($params['nice_classes']); //$search->setrightsOwnerAddress($params['rights_owner_address']); $search->setRightsRepresentative($params['rights_representative']); //$search->setRightsRepresentativeAddress($params['rights_representative_address']); $search->setOfficeOfOrigin($params['office_of_origin']); $search->setDesignatedContractingParty($params['designated_contracting_party']); */ $notEmpty = 0; foreach ($fields as $fl) { $setter = 'set' . UtilsHelper::convertFieldName($fl); if (isset($params[$fl])) { $v = trim($params[$fl]); if ($v) { $notEmpty++; } $search->{$setter}($v); } else { $search->{$setter}(null); } } if ($notEmpty > 0) { $search->save(null, $brand); $success = true; } else { UtilsHelper::setFlashMsg('Моля, въведете критерии за търсене!', UtilsHelper::MSG_ERROR); } //var_dump($search); } $this->success = $success; $this->obj = $search; }
public function executeProductCategoriesList() { $this->setLayout(false); $c = new Criteria(); $this->categories = CategoryPeer::doSelect($c); $prodNum = array(); foreach ($this->categories as $cat) { $id = $cat->getId(); $products = Document::getChildrenOf($cat, "Product", false); // count ACTIVE childrens $cnt = 0; foreach ($products as $product) { if ($product->getPublicationStatus() == UtilsHelper::STATUS_ACTIVE) { $cnt++; } } $prodNum[$id] = $cnt; } $this->prodNum = $prodNum; $this->currentId = $this->getRequestParameter("Category_id"); }
function backend_select($name, $input = null, $option_tags = null, $options = array(), $methode = null) { $code = getDivLabel($options, $name); if ($options['validate']) { $errSpan = "<span id='" . $name . "Error'></span>"; } if ($options['unique']) { if (substr(get_class($input), -4) == "I18n") { $parentClass = substr(get_class($input), 0, -4); } else { $parentClass = null; } if ($input) { $children = Document::getChildrenOf(Document::getParentOf($input->getId(), $parentClass, false), ucfirst($options['model'])); $objListitem = $input->{$methode}(); } else { $children = Document::getChildrenOf(sfContext::getInstance()->getRequest()->getParameter('parent'), ucfirst($options['model'])); $objListitem = null; } foreach ($children as $child) { $listitem = $child->{$methode}(); if ($objListitem != $listitem) { unset($option_tags[$listitem]); } } } $code .= select_tag($name, options_for_select($option_tags, getVal($input, $methode, $name)), clearOptions($options, 1)); $code .= $errSpan; return $code; }
function frontend_select($name, $input = null, $option_tags = null, $options = array(), $methode = null) { $context = sfContext::getInstance(); $request = $context->getRequest(); $errors = $request->getErrors(); //var_dump($errors); if (array_key_exists("err" . $name, $errors)) { $options["class"] .= " error"; } $errSpan = ""; $code = getDivLabel($options, $name); if (array_key_exists('validate', $options)) { $errSpan = "<br><span id='" . $name . "Error'></span>"; } if (array_key_exists('unique', $options)) { $parentClass = null; if ($input) { $children = Document::getChildrenOf(Document::getParentOf($input->getId(), $parentClass, false), ucfirst($options['model'])); $objListitem = $input->{$methode}(); } else { $children = Document::getChildrenOf($request->getParameter('parent'), ucfirst($options['model'])); $objListitem = null; } foreach ($children as $child) { $listitem = $child->{$methode}(); if ($objListitem != $listitem) { unset($option_tags[$listitem]); } } } $code .= select_tag($name, options_for_select($option_tags, getVal($input, $methode, $name)), clearOptions($options, 1)); $code .= $errSpan; return $code; }
public static function getSiteMap($root = null, &$sitemap, $depth = 1000, $level = 1, $path = null, $getIndex = false, $getInvisible = false) { if ($level > $depth) { return array(); } $nolabel = UtilsHelper::Localize("website.frontend.nolabel"); if (!$root) { $root = Rootfolder::getRootfolderByModule("website"); if (!$root) { return; } } if (is_object($root)) { $root = $root->getId(); } $pathSet = false; if (Document::hasChildren($root)) { // $oldRelationsFlag = sfConfig::get('sf_cache_relations'); // sfConfig::set('sf_cache_relations', false); try { $children = Document::getChildrenOf($root, null, true, false); foreach ($children as $child) { // skip Urlrewrite objects if (get_class($child) == "Urlrewrite" || get_class($child) == "Media") { continue; } $href = ""; $label = $nolabel; $childId = $child->getId(); $class = get_class($child); $showItem = true; if (Document::getStatus($child) != UtilsHelper::STATUS_ACTIVE) { continue; } if (!$getIndex && Document::hasTag($child, "website_page_index")) { continue; } if (!$getInvisible) { if ($class == 'Page' && Document::hasTag($child, "website_page_nonvisible") || $class == 'Topic' && Document::hasTag($child, "website_topic_nonvisible")) { $id = $childId; $showItem = false; //continue; } } if ($showItem) { if ($class == "Page") { $type = $child->getPageType(); $secure = $child->getIsSecure(); //$label = $child->getLabel(); $label = $child->getNavigationTitle(); $href = $child->getHref(); $id = $childId; } elseif ($class == "Topic") { $label .= $child->getLabel(); // " (".$child->getLabel().")"; $indexPage = $child->getIndexPage(); $id = 0; if ($indexPage) { //$id = $indexPage->getId(); $id = $childId; $href = $indexPage->getHref(); $label = $indexPage->getLabel(); $type = $indexPage->getPageType(); // if ($type == "REFERENCE") // { // //echo "--- Topic: ".$id." ---\n"; // $pg = Document::getDocumentByCulture($indexPage->getPageId(), null, true); // get PageI18n object // if($pg) // { // $id = $pg->getId(); // $href = $pg->getHref(); // $secure = $pg->getIsSecure(); // } // } } } else { $id = $childId; $label = $child->getLabel(); } } if ($id && !$pathSet) { $path[] = $id; $pathSet = true; } else { $c = count($path); $path[$c - 1] = $id; } $sitemap[$root][$childId]['path'] = $path; $sitemap[$root][$childId]['id'] = $id; $sitemap[$root][$childId]['href'] = $href; $sitemap[$root][$childId]['label'] = $label; if (array_key_exists('secure', $sitemap[$root][$childId])) { $sitemap[$root][$childId]['secure'] = $secure; } $sitemap[$root][$childId]['level'] = $level; $sitemap[$root][$childId]['model'] = $class; $sitemap[$root][$childId]['show'] = $showItem; self::getSiteMap($child->getId(), $sitemap, $depth, $level + 1, $path, $getIndex, $getInvisible); } } catch (Exception $e) { return null; } // sfConfig::set('sf_cache_relations', $oldRelationsFlag); } return $sitemap; }
public function executeGetLastChildId() { $children = Document::getChildrenOf($this->getRequestParameter('parentId'), null, false, false); if ($pos = $this->getRequestParameter('position')) { $cnt = count($children); $last = $children[$cnt - $pos]; } else { $last = array_pop($children); } exit("" . $last); }
public static function updateListCache($listId = null) { if ($listId) { $list = Lists::getListByListId($listId); $lists = array($list); } else { if ($listsRootFolder = Rootfolder::getRootfolderByModule("lists")) { $lists = Document::getChildrenOf($listsRootFolder->getId(), "Lists"); } } foreach ($lists as $list) { $listId = $list->getListId(); $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?>"; FileHelper::writeFile($listPath, $content); } }
public static function deleteDocument($id) { $con = Propel::getConnection(DocumentPeer::DATABASE_NAME); $stmt = $con->createStatement(); $children = $medias = array(); $medias = Document::getChildrenOf($id, "Media"); if ($medias) { foreach ($medias as $media) { $media->delete(); } } $children = Document::getChildrenOf($id, null, false); $sql = "DELETE FROM m_document WHERE m_document.id = {$id}"; $stmt->executeQuery($sql); Document::deleteObjCache($id); foreach ($children as $child) { self::deleteDocument($child); } }
public function getRewriteUrl() { $rewriteUrl = Document::getChildrenOf($this->getId(), 'Urlrewrite'); if (count($rewriteUrl) > 0) { return $rewriteUrl[0]->getLabel(); } else { return null; } }
public static function getLanguageBar($parent, $moduleName = '') { $parentDoc = Document::getDocumentInstance($parent); $children = Document::getChildrenOf($parent, get_class($parentDoc) . "I18n"); $childrenArray = array(); $iconExtension = '.gif'; // if we load an other module tree (config in <mymodule>/config/leftTree.xml param "parent" on tag <objects>) /*$leftTree = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir')."/apps/backend/modules/".strtolower($moduleName)."/config/leftTree.xml"); if ($leftTree[0]['attributes']['PARENT']) { return null; }*/ $i = 0; foreach ($children as $child) { $childClass = get_class($child); $childrenArray[$i]['id'] = $child->getId(); $culture = $child->getCulture(); $con = Propel::getConnection(); $con->begin(); $c = new Criteria(); $c->addAnd(ListitemPeer::VALUE, $culture, Criteria::EQUAL); $cultureObj = ListitemPeer::doSelectOne($c); $childrenArray[$i]['culture'] = $cultureObj; $childrenArray[$i]['type'] = $childClass; $childrenArray[$i]['class'] = strtolower($moduleName) . '_' . strtolower($childClass); $childrenArray[$i]['style'] = "background: url(/images/icons/" . $culture . $iconExtension . ") 0 0 no-repeat;"; $i++; } return $childrenArray; }
<?php $count = $pager->getNbResults(); foreach ($pager->getResults() as $g) { $url = UtilsHelper::cleanURL($g); ?> <h3><a href="<?php echo $url; ?> "><?php echo $g->getLabel(); ?> </a></h3> <?php $images = Document::getChildrenOf($g->getId(), 'Media', false); $cnt = count($images); if ($images[0]) { $img = $images[0]; ?> <a href="<?php echo $url; ?> "><img class="gal_b" src="/media/display/thumb/325/id/<?php echo $img; ?> "></a> <?php } if ($images[1]) { $img = $images[1];
function run_session_search($task, $args) { ini_set("memory_limit", "8192M"); ini_set("display_errors", 1); define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); //sfConfig::set('sf_cache_objects', false); //sfConfig::set('sf_cache_relations', false); //sfConfig::set('sf_use_relations_cache', false); //get all serch templates $c = new Criteria(); $searcheTemplates = SearchPeer::doSelect($c); //$searcheTemplates = array($st); $fields = array('Label', 'ApplicationNumber', 'RegisterNumber', 'RegistrationDate', 'ApplicationDate', 'ExpiresOn', 'ViennaClasses', 'NiceClasses', 'RightsOwner', 'RightsRepresentative', 'OfficeOfOrigin', 'DesignatedContractingParty'); $c = new Criteria(); //$c->add(ImportSessionPeer::CREATED_AT, "2014-11-03", Criteria::GREATER_EQUAL ); $importSessions = ImportSessionPeer::doSelect($c); /*if($args[0] == "-d") { foreach ($importSessions as $importSession) { $res = Document::getChildrenOf($importSession->getId(), "SearchMatch"); foreach ($res as $r) { $r->delete(); echo "."; } } exit(); }*/ $ind = 0; foreach ($importSessions as $importSession) { $found = false; if ($importSession->getTmCount() == 0) { continue; } $searchMatches = Document::getChildrenOf($importSession->getId(), "SearchMatch", false); //if($importSession->getId() == 552172) continue; if (count($searchMatches) > 0) { continue; } echo ">>> searching session: " . $importSession->getId() . "\n"; try { $sti = 1; foreach ($searcheTemplates as $searcheTemplate) { $searchOf = array(); foreach ($fields as $field) { $getter = "get" . $field; $param = $searcheTemplate->{$getter}(); if ($param) { $param = str_replace(array('+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', ':', '\\', '.', '/'), array('\\+', '\\-', '\\&&', '\\||', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\"', '\\~', '\\:', '\\\\', '\\.', '\\/'), $param); $searchOf[$field] = 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 '; } if ($field == "NiceClasses" || $field == "ViennaClasses") { $query .= '('; $parts = explode(",", $term); foreach ($parts as $el) { for ($e = 1; $e < 15; $e++) { $query .= $field . $e . ':"' . trim($el) . '" OR '; } } $query = substr($query, 0, -4) . ')'; } elseif ($field == "ApplicationNumber" || $field == "RegisterNumber") { $query .= $field . ':'; $query .= trim($term); } else { $query .= $field . ':'; if (strpos($term, "*") !== false || strpos($term, "?") !== false) { $query .= trim(UtilsHelper::cyrillicConvert($term)); } else { $query .= trim(UtilsHelper::cyrillicConvert($term)) . '~0.7'; } } $i++; } $q = Zend_Search_Lucene_Search_QueryParser::parse($query); //////////////////////// SEARCH EXECUTION //////////////////// echo " | " . $sti . " > " . $searcheTemplate->getId(); $searchIndex = Zend_Search_Lucene::open(sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'search/' . $importSession->getId() . "/"); $searchResults = $searchIndex->find($q); $brandId = Document::getParentOf($searcheTemplate->getId(), "Brand", false); foreach ($searchResults as $searchResult) { if ($foundEls[$searchResult->did] == $brandId) { continue; } $foundEls[$searchResult->did] = $brandId; $found = true; $sm = new SearchMatch(); $sm->setLabel("Match"); $sm->setImportSession($importSession->getId()); $sm->setSearch($searcheTemplate->getId()); $sm->setTrademark($searchResult->did); $sm->save(null, $importSession); } $sti++; } if ($found) { UtilsHelper::sendEmail(UtilsHelper::Settings('main_email'), "Matches have been found, click below to see them <br> <a href='http://www.tm-smart.com/import-session-report.html?is=" . $importSession->getId() . "'>http://www.tm-smart.com/import-session-report.html?is=" . $importSession->getId() . "</a>", "TM Smart - Matches foud"); $ind++; } else { // UtilsHelper::sendEmail(UtilsHelper::Settings('main_email'), "No matches have been found", "TM Smart - No matches foud"); } } catch (Exception $e) { echo ">>>>>>>>>> Error on Session " . $importSession->getId() . "\n" . $e->getMessage(); continue; //echo_cms_error("ERROR: ".$e->getMessage()); } if ($ind > 10) { break; } } //sfConfig::set('sf_cache_objects', true); //sfConfig::set('sf_cache_relations', true); //sfConfig::set('sf_use_relations_cache', true); }
public function executeSendNewsletter() { $mailinglistsFolder = Document::getDocumentByExclusiveTag("newsletter_folder_mailinglist"); if ($mailinglistsFolder) { $this->mailinglists = Document::getChildrenOf($mailinglistsFolder->getId(), "Mailinglist"); } $this->items = $this->getRequestParameter('items'); $mls = explode(",", $this->items); foreach ($mls as $ml) { $obj = Document::getDocumentInstance($ml); if (!$obj || get_class($obj) != "Newsletter") { exit("<br><br>Please choose at least one newsletter"); } } }
public function executeFolderDetail() { $this->setLayout(false); $this->images = Document::getChildrenOf($this->getRequestParameter('id'), "Media"); }