예제 #1
0
 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;
 }
예제 #2
0
파일: Newsletter.php 프로젝트: kotow/work
 public function save($con = null, $parent = null)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         if (!$this->getId()) {
             $genDoc = Document::getGenericDocument($this);
             $genDoc->setPublicationStatus("WAITING");
             $genDoc->save();
             $this->setId($genDoc->getId());
         }
         parent::save($con);
         // create relationship
         if (!$parent && !Document::getParentOf($this->getId())) {
             $parent = Rootfolder::getRootfolder($this);
         }
         Relation::saveRelation($parent, $this);
         $con->commit();
         Document::cacheObj($this, get_class($this));
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
예제 #3
0
 public function executeDetails2()
 {
     header("Content-type: text/html; charset=utf-8");
     $this->setLayout(false);
     $sm = Document::getDocumentInstance($this->getRequestParameter('SearchMatch_id'));
     $this->st = Document::getDocumentInstance($sm->getSearch());
     $this->sm = $sm;
     $this->parentBrand = Document::getParentOf($sm->getSearch(), "Brand");
     if (get_class($sm) == 'SearchMatch') {
         $fields = array('Label', 'ApplicationNumber', 'RegisterNumber', 'RegistrationDate', 'ApplicationDate', 'ExpiresOn', 'ViennaClasses', 'NiceClasses', 'RightsOwner', 'RightsRepresentative', 'OfficeOfOrigin', 'DesignatedContractingParty');
         $template = Document::getDocumentInstance($sm->getSearch());
         if ($template) {
             $searchOf = array();
             foreach ($fields as $field) {
                 $getter = "get" . $field;
                 $v = $template->{$getter}();
                 if ($v) {
                     $searchOf[] = $field;
                 }
             }
         }
         $this->searchOf = $searchOf;
         $this->brand = Document::getDocumentInstance($sm->getTrademark());
     } else {
         $this->brand = null;
     }
 }
예제 #4
0
파일: Listitem.php 프로젝트: kotow/work
 public function save($con = null, $parent = null)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         if (!$this->getId()) {
             $this->setId(Document::getGenericDocument($this)->getId());
         }
         parent::save($con);
         // create relationship
         if (!$parent && !Document::getParentOf($this->getId())) {
             $parent = Rootfolder::getRootfolder($this);
         }
         Relation::saveRelation($parent, $this);
         $con->commit();
         Document::cacheObj($this, get_class($this));
         // get Lists object
         if (!$parent) {
             $parent = Document::getParentOf($this->getId());
         }
         // update list cache
         if (get_class($parent) == "Lists") {
             Lists::updateListCache($parent->getListId());
         }
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
예제 #5
0
파일: Tag.php 프로젝트: kotow/work
 public function save($con = null, $parent = null)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         if (!$this->getId()) {
             $this->setId(Document::getGenericDocument($this)->getId());
         }
         parent::save($con);
         // create relationship
         if (!$parent && !Document::getParentOf($this->getId())) {
             $parent = Rootfolder::getRootfolder($this);
         }
         Relation::saveRelation($parent, $this);
         $con->commit();
         if (sfConfig::get('sf_cache_relations')) {
             Tagrelation::updateTagRelationCache();
         }
         Document::cacheObj($this, get_class($this));
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
예제 #6
0
 public function executeEditListitemI18n()
 {
     BackendService::objectEdit('lists', 'ListitemI18n', $this);
     if ($user = $this->getUser()->getSubscriber()) {
         $this->userType = $user->getType();
     }
     if ($this->obj) {
         if ($parentI18 = Document::getParentOf($this->obj->getId())) {
             if ($parent = Document::getParentOf($parentI18)) {
                 $this->listType = $parent->getListType();
                 //if($parent->getListId() == "brokers") $this->showvalue = true;
             }
         }
     }
 }
예제 #7
0
파일: User.php 프로젝트: kotow/work
 public function save($con = null, $parent = null)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         if (trim($this->__toString()) != "") {
             $this->setLabel($this->__toString());
         }
         switch ($this->getType()) {
             case "admin":
                 //case "site_admin":
                 $this->setBackend(1);
                 break;
             default:
                 $this->setBackend(0);
         }
         if ($this->getLogin() == "") {
             $this->setLogin($this->getEmail());
         }
         if (!$this->getId()) {
             $this->setId(Document::getGenericDocument($this)->getId());
         }
         /*if (!$this->getPublicationStatus())
         		{
         			$this->setPublicationStatus(UtilsHelper::STATUS_ACTIVE);
         		}*/
         parent::save($con);
         // create relationship
         if (!$parent && !Document::getParentOf($this->getId())) {
             $parent = Rootfolder::getRootfolder($this);
         }
         Relation::saveRelation($parent, $this);
         $con->commit();
         Document::cacheObj($this, get_class($this));
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
예제 #8
0
}
?>
</div>
				</div>
			</div>
			<div class="qfSearchListWrap qfBoxBorderBg">
				
				<form method="POST">
				<input type="submit" value="Изтрий избрани" style="float:left"/>
				<br />
				<br />

				<?php 
$fields = array('Label', 'ApplicationNumber', 'RegisterNumber', 'RegistrationDate', 'ApplicationDate', 'ExpiresOn', 'ViennaClasses', 'NiceClasses', 'RightsOwner', 'RightsRepresentative', 'OfficeOfOrigin', 'DesignatedContractingParty');
foreach ($pager->getResults() as $doc) {
    $brand = Document::getParentOf($doc->getSearch(), "Brand");
    if (!$brand) {
        continue;
    }
    ?>
					
						<div class="qfRepImpSsItem">

							<div class="qfRepImpSsCol qfRepImpSsLeft">
								<div class="qfRepImpSsColInn">
								
								<div class="check_delete"><input type="checkbox" name="del[]" value="<?php 
    echo $doc->getId();
    ?>
"></div>
								
예제 #9
0
 public function executeDelete()
 {
     if ($user = $this->getUser()->getSubscriber()) {
         $userType = $user->getType();
     }
     if ($selectedDocuments = $this->getRequestParameter("selectedDocuments")) {
         sfConfig::set('sf_cache_relations', false);
         $selectedDocuments = explode(",", $selectedDocuments);
         foreach ($selectedDocuments as $docId) {
             $document = Document::getDocumentInstance($docId);
             if ($document) {
                 if ($userType != "admin") {
                     $class = get_class($document);
                     if ($class == "Lists" && $document->getListType() == "system") {
                         $alert = "no_delete";
                         continue;
                     } else {
                         if ($class == "Listitem") {
                             if ($parent = Document::getParentOf($document->getId())) {
                                 if ($parent->getListType() == "system") {
                                     $alert = "no_delete";
                                     continue;
                                 }
                             }
                         }
                     }
                 }
                 $document->delete();
             }
         }
         sfConfig::set('sf_cache_relations', true);
         Relation::updateRelationCache($this->getRequestParameter("p"));
     } else {
         $document = Document::getDocumentInstance($this->getRequestParameter('id'));
         if ($document) {
             $class = get_class($document);
             if ($userType != "admin") {
                 if ($class == "Lists" && $document->getListType() == "system") {
                     $alert = "no_delete";
                 } else {
                     if ($class == "Listitem") {
                         if ($parent = Document::getParentOf($document->getId())) {
                             if ($parent->getListType() == "system") {
                                 $alert = "no_delete";
                             }
                         }
                     }
                 }
             }
             if ($alert != "no_delete") {
                 $document->delete();
             }
         }
     }
     exit($alert);
 }
예제 #10
0
파일: Relation.php 프로젝트: kotow/work
 public static function saveRelation($parents, $document, $updateCache = true)
 {
     if ($parents) {
         try {
             $con = Propel::getConnection();
             $con->begin();
             $docId = $document->getId();
             if (!is_array($parents)) {
                 $parents = array($parents);
             }
             foreach ($parents as $parent) {
                 $saveNew = true;
                 if ($parent) {
                     $parentId = $parent->getId();
                     $oldParentId = Document::getParentOf($docId, null, false);
                     if ($oldParentId) {
                         $relation = RelationPeer::retrieveByPk($oldParentId, $docId);
                         if ($oldParentId != $parentId) {
                             $relation->delete();
                         } else {
                             $saveNew = false;
                         }
                     }
                     if ($saveNew) {
                         $relation = new Relation();
                         $relation->setId1($parentId);
                         $relation->setId2($docId);
                         $relation->setDocumentModel1(get_class($parent));
                         $relation->setDocumentModel2(get_class($document));
                         $relation->setSortOrder($relation->getNextSortOrder($parent, $document));
                     }
                     $relation->save();
                 }
             }
             $con->commit();
             if (sfConfig::get('sf_cache_relations') && $updateCache && $parentId) {
                 self::updateRelationCache($parentId);
             }
             return true;
         } catch (Exception $e) {
             $con->rollback();
             throw $e;
         }
     }
 }
예제 #11
0
 public function validateAccountCreate()
 {
     // default values
     $result = true;
     $this->termsUrl = "";
     $this->type = "user";
     $this->company = null;
     $session_user = $this->getUser();
     $this->user = $session_user->getSubscriber();
     $request = $this->getRequest();
     if ($company = Document::getParentOf($session_user->getSubscriberId(), "Company")) {
         $this->company = $company;
     }
     if ($this->user) {
         $type = $this->user->getUserType();
         if ($type == 0) {
             $this->type = "company";
         }
     } elseif ($this->getRequestParameter("acc")) {
         $this->type = $this->getRequestParameter("acc");
     }
     if ($this->getRequestParameter('submitted') == "submitted") {
         $culture = $this->getUser()->getCulture();
         $params = $request->getParameterHolder()->getAll();
         foreach ($params as $key => $param) {
             if (!is_array($param)) {
                 ${$key} = trim($param);
             } else {
                 ${$key} = $param;
             }
         }
         /******* COMMON ********/
         /* firstname */
         /*if(empty($firstname))
         		{
         			$request->setError('errfirstname', "Please fill the 'First name' field");
         			$result = false;
         		}*/
         /* end firstname */
         /* e-mail */
         if (!$this->user) {
             if (empty($email)) {
                 $request->setError('erremail', "Please fill the 'Email' field");
                 $result = false;
             } else {
                 $myValidator = new sfEmailValidator();
                 $myValidator->initialize($this->getContext(), array());
                 $email = urldecode($email);
                 if (!$myValidator->execute($email, $error)) {
                     $request->setError('erremail', "This email is not valid");
                     $result = false;
                 } else {
                     if (!$this->user) {
                         $c = new Criteria();
                         $c->add(UserPeer::LOGIN, $email, Criteria::EQUAL);
                         $c1 = $c->getNewCriterion(UserPeer::LOGIN, $email, Criteria::EQUAL);
                         $c2 = $c->getNewCriterion(UserPeer::EMAIL, $email, Criteria::EQUAL);
                         $c1->addOr($c2);
                         $c->add($c1);
                         $user = UserPeer::doSelectOne($c);
                         if ($user) {
                             $request->setError('erremail', "Your email already exists in our database");
                             $result = false;
                         }
                     }
                 }
             }
         }
         /* end e-mail */
         /* pass */
         /*if(empty($password) && !$this->user)
         		{
         		$request->setError('errpassword', "Please fill the 'Password' field");
         		$result = false;
         		}
         		else
         		{
         		if(strlen($password) < 4 && !$this->user)
         		{
         		$request->setError('errpassword', "Your password must be more than 4 chars long");
         		$result = false;
         		}
         		elseif($this->user && strlen($password) > 0 && strlen($password) < 4)
         		{
         		$request->setError('errpassword', "Your password must be more than 4 chars long");
         		$result = false;
         		}
         		elseif(empty($confirmpass) && !$this->user)
         		{
         		$request->setError('errpassword', "Your password confirmation do not match");
         		$result = false;
         		}
         		elseif(empty($confirmpass) && $this->user && strlen($password) > 0)
         		{
         		$request->setError('errpassword', "Your password confirmation do not match");
         		$result = false;
         		}
         		else
         		{
         		if($password != $confirmpass)
         		{
         		$request->setError('errpassword', "Your password confirmation do not match");
         		$result = false;
         		}
         		}
         		}*/
         /* end pass */
         /* phone
         			if(empty($phone))
         			{
         			$request->setError('errphone', "Please fill the 'phone' field");
         			$result = false;
         			}
         			end phone */
         if (!$this->user) {
             /* captcha */
             if (empty($captcha_code)) {
                 $request->setError('errcaptcha_code', "Please fill the 'Verification code' field");
                 $result = false;
             } else {
                 $code = $this->getUser()->getAttribute('captcha_code');
                 if (!$this->user && $code != $captcha_code) {
                     $request->setError('errcaptcha_code', "Wrong verification code");
                     $result = false;
                 }
             }
             /* end captcha */
             /* terms */
             if (empty($terms)) {
                 $request->setError('errterms', "You must accept the terms and conditions");
                 $result = false;
             }
             /* end terms */
         }
         /***** END COMMON *****/
         /******* COMPANY ********/
         if ($this->type == "company") {
             /* label */
             if (empty($label)) {
                 $request->setError('errlabel', "Please fill the 'Company name' field");
                 $result = false;
             }
             /* end label */
             /* country */
             if (empty($country)) {
                 $request->setError('errcountry', "Please fill the 'Country' field");
                 $result = false;
             }
             /* end country */
             /* description */
             if (empty($description)) {
                 $request->setError('errdescription', "Please fill the 'Description' field");
                 $result = false;
             }
             if ($request->getFileSize("logo") > 0) {
                 try {
                     $this->media = Media::upload('logo', "upload", array("image/gif", "image/png", "image/jpeg", "image/pjpeg", "image/x-png"));
                     if ($this->media && $this->media->IsImage()) {
                         $this->media->resizeImage(null, null, 800);
                         $this->media->resizeImage("thumbs", null, 100);
                     }
                 } catch (Exception $e) {
                     $request->setError('errlogo', UtilsHelper::Localize("media.backend." . $e->getMessage()));
                     $result = false;
                 }
             }
             /* end country */
             /* city
             			if(empty($city))
             			{
             			$request->setError('errcity', "Please fill the 'city' field");
             			$result = false;
             			}
             			end city */
             /* zip
             			if(empty($zip))
             			{
             			$request->setError('errzip', "Please fill the 'zip' field");
             			$result = false;
             			}
             			else
             			{
             			$myValidator = new sfNumberValidator();
             			$myValidator->initialize($this->getContext(), array(
             			'type' 	=>	"int"
             			));
             			if (!$myValidator->execute($zip, $error))
             			{
             			$request->setError('errzip', "The 'zip' field must be a number");
             			$result = false;
             			}
             			}
             			end zip */
             /* address
             			if(empty($address))
             			{
             			$request->setError('erraddress', "Please fill the 'adress' field");
             			$result = false;
             			}
             			end address */
         }
         /***** END COMPANY *****/
         /******** USER *********/
         if ($this->type == "user" && $request->getFileSize("cv") > 0) {
             try {
                 $this->media = Media::upload('cv', "upload", array("application/rtf", "application/msword", "text/plain", "text/richtext", "text/rtf", "application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.oasis.opendocument.text", "text/html"));
             } catch (Exception $e) {
                 $request->setError('errcv', UtilsHelper::Localize("media.backend." . $e->getMessage()));
                 $result = false;
             }
         }
         /****** END USER *******/
     }
     return $result;
 }
예제 #12
0
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;
}
예제 #13
0
<?php

/*
	echo MenuHelper::get_menu_by_tag("website_menu_main",
	array(
		'depth' => 1,
		'mainMasterClass' => 'menu-top',
		'currentAClass' => 'selected',
		'lastItemClass' => 'last'
		));
*/
$pageRef = $sf_params->get('pageref');
$topicId = Document::getParentOf($pageRef, null, false);
if ($sf_user->isAuthenticated()) {
    ?>
	<ul class="qfMainNavList">
<?php 
    $ind = 0;
    foreach ($menuItems as $tId => $p) {
        $ind++;
        ?>
		<li class="qfMNavList0<?php 
        echo $ind;
        ?>
 <?php 
        if ($tId == $topicId) {
            echo 'qfMNavListActive';
        }
        ?>
">
			<a href="<?php 
예제 #14
0
파일: MenuHelper.php 프로젝트: kotow/work
 public static function buildMenu($root, $menuItems = array(), $rootId = null, $options = array(), $siteMap = null)
 {
     $defOptionsArr = array("hasTags" => false, "mainMasterClass" => false, "mainMasterStyle" => false, "mainMasterId" => false, "mainClass" => false, "mainSubClass" => false, "firstItemClass" => false, "lastItemClass" => false, "itemClass" => false, "currentItemClass" => false, "mainTag" => false, "subTag" => false, "aClass" => false, "currentAClass" => false, "separator" => false, "depth" => false, "hideSecure" => false, "hideLabel" => false, "inPath" => false, "getIndex" => false, "splitElements" => 0);
     $class = null;
     foreach ($defOptionsArr as $okey => $oval) {
         if (!array_key_exists($okey, $options)) {
             $options[$okey] = false;
         }
     }
     if ($options['inPath'] && !$siteMap) {
         self::getSiteMap(null, $siteMap, 1000, 1, null, false, true);
     }
     $sfcontext = sfContext::getInstance();
     if (!$rootId) {
         if (is_object($root)) {
             $root = $root->getId();
         }
         $rootId = $root;
         $depth = isset($options['depth']) ? $options['depth'] : 1000;
         $menuItems = self::getSiteMap($rootId, $menuItems, $depth, 1, null, $options['getIndex']);
         if (isset($options["mainMasterClass"])) {
             $class = $options["mainMasterClass"];
         }
         //			if ($options["mainMasterId"])
         //				$masterId = $options["mainMasterId"];
         //			if ($options["mainMasterStyle"])
         //				$masterStyle = $options["mainMasterStyle"];
         $options['depth'] = $depth;
     }
     if (!isset($class) && isset($options["mainSubClass"])) {
         $class = $options["mainSubClass"];
     }
     if (isset($options["mainClass"])) {
         $class .= ' ' . $options["mainClass"];
     }
     if (isset($options["splitElements"]) && is_numeric($options["splitElements"])) {
         $splitElements = intval($options["splitElements"]);
     } else {
         $splitElements = 0;
     }
     $tag = $options["mainTag"] ? $options["mainTag"] : "ul";
     $subTag = $options["subTag"] && ($tag != "ul" || $tag != "ol") ? $options["subTag"] : "li";
     $add = '';
     if ($class) {
         $add .= ' class="' . $class . '"';
     }
     if (isset($options["mainMasterId"])) {
         $add .= ' id="' . $options["mainMasterId"] . '"';
     }
     if (isset($options["mainMasterStyle"])) {
         $add .= ' style="' . $options["mainMasterStyle"] . '"';
     }
     if ($tag != 'none') {
         $content = "<{$tag}" . $add . ">\n";
     }
     $i = 1;
     $j = $i;
     if (array_key_exists($rootId, $menuItems)) {
         $nbr = count($menuItems[$rootId]);
         // prepare "inPath" checker
         if ($options['inPath'] && ($options['currentItemClass'] || $options['currentAClass'])) {
             $pageref = $sfcontext->getRequest()->getParameter("pageref");
             if ($par = Document::getParentOf($pageref)) {
                 $parId = $par->getId();
                 if ($up = Document::getParentOf($parId)) {
                     $upId = $up->getId();
                 }
             }
         }
         foreach ($menuItems[$rootId] as $k => $item) {
             if (!$item['show']) {
                 continue;
             }
             // skip hidden items
             $newOptions = array();
             foreach ($options as $key => $option) {
                 $newOptions[$key] = str_replace("%INDEX%", $i, $option);
             }
             if ($newOptions['hideLabel']) {
                 $label = "";
             } else {
                 $label = $item['label'];
             }
             if ($item['model'] != "Website" && $item['model'] != "Menu") {
                 if ($newOptions['separator'] && $i > 1) {
                     $content .= $newOptions['separator'];
                 }
                 if ($newOptions["hideSecure"] == true) {
                     if (!isset($authentificated)) {
                         $user = $sfcontext->getUser();
                         $authentificated = $user->isAuthenticated();
                     }
                     if ($item["secure"] == 1 && $authentificated == false) {
                         continue;
                     }
                 }
                 $itemClass = '';
                 if ($newOptions['currentItemClass']) {
                     if (isset($newOptions['inPath'])) {
                         $existInPath = in_array($item['id'], $siteMap[$upId][$parId]['path']);
                     }
                     if (!isset($existInPath)) {
                         $existInPath = false;
                     }
                     if ($pageref == $item['id'] || $existInPath) {
                         $itemClass = $newOptions['currentItemClass'];
                     }
                 }
                 if ($newOptions["itemClass"]) {
                     $itemClass = $newOptions["itemClass"];
                 }
                 if ($i == 1 && $newOptions['firstItemClass']) {
                     $itemClass .= " " . $newOptions['firstItemClass'];
                 }
                 if ($i == $nbr && $newOptions['lastItemClass']) {
                     $itemClass .= " " . $newOptions['lastItemClass'];
                 }
                 if ($itemClass) {
                     $itemClass = " class='" . trim($itemClass) . "'";
                 }
                 $existInPath = false;
                 $aClass = ' class="';
                 if ($newOptions['currentAClass']) {
                     if ($newOptions['inPath']) {
                         $existInPath = in_array($item['id'], $siteMap[$upId][$parId]['path']);
                     }
                     if (!isset($existInPath)) {
                         $existInPath = false;
                     }
                     if ($pageref == $item['id'] || $existInPath) {
                         $aClass .= $newOptions['currentAClass'];
                     }
                 }
                 if ($newOptions['aClass']) {
                     $aClass .= ' ' . $newOptions['aClass'];
                 }
                 $aClass .= '" ';
                 if (empty($item["href"])) {
                     if ($tag != 'none') {
                         $content .= "<{$subTag}" . $itemClass . "><a href=\"javascript:void(0)\" " . $aClass . ">" . $label . "</a>\n";
                     } else {
                         $content .= "<a href=\"javascript:void(0)\" " . $aClass . ">" . $label . "</a>\n";
                     }
                 } else {
                     if ($tag != 'none') {
                         $content .= "<{$subTag}" . $itemClass . "><a href=\"" . $item['href'] . "\"" . $aClass . " title=\"" . $item['label'] . "\">" . $label . "</a>\n";
                     } else {
                         $content .= "<a href=\"" . $item['href'] . "\"" . $aClass . " title=\"" . $item['label'] . "\">" . $label . "</a>\n";
                     }
                 }
             }
             if (array_key_exists($k, $menuItems) && $menuItems[$k] && $item['level'] < $newOptions['depth']) {
                 $content .= self::buildMenu(null, $menuItems, $k, $options);
             }
             if ($item['model'] != "Website" && $item['model'] != "Menu") {
                 if ($tag != 'none') {
                     $content .= "</{$subTag}>\n";
                 }
             }
             $i++;
             $j++;
             if ($splitElements && $j > $splitElements) {
                 if ($tag != 'none') {
                     $content .= "</{$tag}>\n";
                     $add = '';
                     if ($class) {
                         $add .= " class='{$class}'";
                     }
                     $content .= "<{$tag}" . $add . ">\n";
                 }
                 $j = 1;
             }
         }
     }
     if ($tag != 'none') {
         $content .= "</{$tag}>\n";
     }
     return $content;
 }
예제 #15
0
 public function executeProductDetails()
 {
     $this->setLayout(false);
     $id = $this->getRequestParameter("Product_id");
     $category = $this->category = Document::getParentOf($id);
     //Document::getParentOf($id, "Category");
     if ($category) {
         $this->getRequest()->setParameter("Category_id", $this->category->getId());
     }
     $product = $this->product = Document::getDocumentInstance($id);
     if ($product) {
         $this->mainImg = Document::getDocumentInstance($product->getImage());
         $this->images = Document::getChildrenOf($id, "Media");
     }
 }
예제 #16
0
 public static function objectSave(&$obj, &$parent, $documentName = null)
 {
     try {
         $parameters = sfContext::getInstance()->getRequest()->getParameterHolder()->getAll();
         if (!$documentName) {
             $documentName = $parameters["documentName"];
         }
         if (!$parent) {
             $parent = Document::getDocumentInstance($parameters['parent']);
         }
         if (!$parent) {
             if (isset($parameters["parentModule"])) {
                 $parent = Rootfolder::getRootfolderByModule($parameters["parentModule"]);
             } else {
                 $parent = Rootfolder::getRootfolderByModule($moduleName);
             }
         }
         if (!is_object($obj)) {
             if (is_numeric($parameters['id']) && !$parent) {
                 $obj = Document::getDocumentInstance($parameters['id']);
                 $parent = Document::getParentOf($parameters['id']);
                 $documentName = $parameters["documentName"];
             } else {
                 $obj = new $documentName();
             }
         }
         include_once sfConfig::get('sf_root_dir') . "/config/Schema.class.php";
         $m = "get" . $documentName . "Properties";
         $properties = Schema::$m();
         $contentArr = array();
         foreach ($parameters as $key => $value) {
             // parse Content attribute/s for Page
             if ($documentName == "Page" && substr($key, 0, 11) == 'attrContent' && $key > 'attrContent' && in_array('Content', $properties)) {
                 $ind = intval(substr($key, 11));
                 // check if creating NEW Page
                 if ($ind == 0) {
                     $ind = 1;
                 }
                 $contentArr[$parameters['contentID' . $ind]] = '<block id="' . $parameters['contentID' . $ind] . '" target="' . $parameters['contentTarget' . $ind] . '" action="richtext"><![CDATA[' . $value . ']]></block>';
             } else {
                 if (!(strpos($key, 'attr') === false) && $key != "attrRewriteUrl") {
                     if ($value == '') {
                         $value = null;
                     }
                     $key = str_replace('attr', '', $key);
                     if ($properties && $key != "Password" && !in_array($key, $properties)) {
                         continue;
                     }
                     if ($key == "Password" && empty($value)) {
                         continue;
                     }
                     $function = 'set' . $key;
                     if (is_array($value)) {
                         // date field
                         if (array_key_exists('year', $value) || array_key_exists('month', $value) || array_key_exists('day', $value)) {
                             //$value = implode('-', $value);
                             //							$date = $value['year'].'-'.str_pad($value['month'], 2, "0", STR_PAD_LEFT).'-'.str_pad($value['day'], 2, "0", STR_PAD_LEFT); // 2009-02-09 16:10:20
                             $date = implode('-', $value);
                             if ($value['hour'] && $value['minute']) {
                                 // if 'include_custom' is used
                                 if (empty($value['year']) || empty($value['month']) || empty($value['day']) || empty($value['hour']) || empty($value['minute'])) {
                                     $value = null;
                                 } else {
                                     $time = $value['hour'] . ':' . $value['minute'];
                                     $value = $date . ' ' . $time;
                                 }
                             } else {
                                 // if 'include_custom' is used
                                 if (empty($value['year']) && empty($value['month']) && empty($value['day'])) {
                                     $value = null;
                                 } else {
                                     $value = $date;
                                 }
                             }
                         } else {
                             $value = implode(";", $value);
                         }
                     }
                     if ($key == "Related") {
                         if ($value) {
                             $value = '[' . str_replace(';', '][', $value) . ']';
                             $value = str_replace('[]', '', $value);
                         }
                     }
                     if ($key == "Keywords") {
                         if ($value) {
                             $value = '[' . str_replace(',', '][', $value) . ']';
                             $value = str_replace('[]', '', $value);
                         }
                     }
                     $obj->{$function}($value);
                 }
             }
         }
         // Page content save
         if ($documentName == 'Page' && count($contentArr) > 0) {
             // add original NON-RICHTEXT content blocks
             $orgContent = $obj->getContent();
             $blocks = self::get_content_blocks($orgContent);
             foreach ($blocks as $name => $block) {
                 $contentArr[$name] = '<block id="' . $name . '" target="' . $block['target'] . '" action="' . $block['action'] . '"><![CDATA[' . $block['content'] . ']]></block>';
             }
             $allBlocks = PanelService::get_all_content_blocks($orgContent);
             $content = '';
             foreach ($allBlocks as $blockName => $blockData) {
                 $content .= $contentArr[$blockName];
             }
             $content = '<?xml version="1.0" encoding="UTF-8"?><blocks>' . $content . '</blocks>';
             $obj->setContent($content);
         }
         if ($documentName == "Page") {
             $obj->setRewriteUrl($parameters["attrRewriteUrl"]);
         }
         $obj->save(null, $parent);
         if ($tags = Document::getAvailableTagsOf($parameters['moduleName'], $documentName)) {
             foreach ($tags as $tag) {
                 if ($parameters['tag_id_' . $tag->getId()]) {
                     Document::addTag($obj, $tag->getTagId());
                 } else {
                     Document::removeTag($obj, $tag->getTagId());
                 }
             }
             Tagrelation::updateTagRelationCache();
         }
         //UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #17
0
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;
}
예제 #18
0
 public function executeEditGalleryMedia()
 {
     try {
         $request = $this->getRequest();
         //			$params = array();
         if ($id = $this->getRequestParameter("id")) {
             $media = Document::getDocumentInstance($id);
             $parentId = Document::getParentOf($id, null, false);
             $request->setParameter("parent", $parentId);
             $request->setParameter("attrLabel", $parentId . " gallery pic");
             if ($this->getRequestParameter("submitted")) {
                 if ($pathParam = trim($this->getRequestParameter("gp"))) {
                     $pathAdd = DIRECTORY_SEPARATOR . str_replace("_", DIRECTORY_SEPARATOR, $pathParam);
                 }
                 // check for TAGged folder
                 if ($parent = Document::getDocumentByExclusiveTag('media_folder_' . $pathParam, false)) {
                     $this->getRequest()->setParameter("parent", $parent->getId());
                 }
                 $allowedParam = trim($this->getRequestParameter("allowed"));
                 if ($allowedParam == "images") {
                     //if ($allowedParam == "images" || empty($allowedParam))
                     $allowedArr = array("image/gif", "image/jpeg", "image/pjpeg");
                 } elseif (!empty($allowedParam)) {
                     $allowedArr = explode(",", $this->getRequestParameter("allowed"));
                 }
                 $media = Media::upload('galPic', "upload" . $pathAdd, $allowedArr, false);
                 //					$media = Media::upload('galPic', "upload", $allowedArr, false);
                 if ($media && $media->IsImage()) {
                     $fileName = $media->getServerAbsoluteUrl();
                     //$media->getFiledirpath().$media->getFilename();
                     list($w, $h) = getimagesize($fileName);
                     $params['gw'] = $this->getRequestParameter("gw");
                     $params['gh'] = $this->getRequestParameter("gh");
                     $params['gtw'] = $this->getRequestParameter("gtw");
                     $params['gth'] = $this->getRequestParameter("gth");
                     $params['gcw'] = $this->getRequestParameter("gcw");
                     $params['gch'] = $this->getRequestParameter("gch");
                     $cropData = array(0, 0);
                     if ($params['gcw'] || $params['gch']) {
                         if ($params['gcw'] && $params['gch']) {
                             $cropData = array($params['gcw'], $params['gch']);
                         } else {
                             if ($params['gcw']) {
                                 $cropData = array($params['gcw'], 0);
                             } else {
                                 $cropData = array(0, $params['gch']);
                             }
                         }
                     }
                     if ($params['gw'] || $params['gh']) {
                         if ($params['gw'] > 0 && $w > $params['gw'] || $params['gh'] > 0 && $h > $params['gh']) {
                             $media->resizeImage(null, $params['gh'], $params['gw'], null, $cropData);
                         } else {
                             $media->resizeImage(null, null, 800, null, $cropData);
                         }
                     } else {
                         $media->resizeImage(null, null, 800, null, array(800, 600));
                     }
                     // thumbs
                     if ($params['gtw'] || $params['gth']) {
                         $media->resizeImage("thumbs", $params['gth'], $params['gtw']);
                     } else {
                         if ($h > $w) {
                             $media->resizeImage("thumbs", 80, null, null, array(120, 80));
                         } else {
                             $media->resizeImage("thumbs", null, 120, null, array(120, 80));
                         }
                     }
                     /*						if ($h > $w)
                     						{
                     							$media->resizeImage(null, 600);
                     							$media->resizeImage(1, 80, null, null, array(120, 80));
                     						}
                     						else
                     						{
                     							$media->resizeImage(null, null, 800);
                     							$media->resizeImage(1, null, 120, null, array(120, 80));
                     						}*/
                 }
             }
             $this->description = $media->getDescription();
             $this->newId = $media->getId();
         }
     } catch (Exception $e) {
         //			$this->message = $e->getMessage();
         $this->message = UtilsHelper::Localize("media." . $e->getMessage());
     }
 }
예제 #19
0
파일: Page.php 프로젝트: kotow/work
 public function getBreadcrumb()
 {
     $breadcrumb = array();
     $parent = Document::getParentOf($this->getId());
     while ($parent) {
         if (get_class($parent) == 'Topic') {
             $breadcrumb[] = $parent;
         }
         if (get_class($parent) == 'Menu' || get_class($parent) == 'Website') {
             break;
         }
         $parent = Document::getParentOf($parent->getId());
     }
     $breadcrumb[] = Document::getDocumentByExclusiveTag('website_page_home');
     return array_reverse($breadcrumb);
 }
예제 #20
0
 public static function objectSave(&$obj, &$parent, $documentName = null)
 {
     try {
         $parameters = sfContext::getInstance()->getRequest()->getParameterHolder()->getAll();
         if (!$documentName) {
             $documentName = $parameters["documentName"];
         }
         if (!$parent) {
             $parent = Document::getDocumentInstance($parameters['parent']);
         }
         if (!is_object($obj)) {
             if (is_numeric($parameters['id']) && !$parent) {
                 $obj = Document::getDocumentInstance($parameters['id']);
                 $parent = Document::getParentOf($parameters['id']);
                 $documentName = $parameters["documentName"];
             } else {
                 $obj = new $documentName();
             }
         }
         include_once sfConfig::get('sf_root_dir') . "/config/Schema.class.php";
         $m = "get" . $documentName . "Properties";
         $properties = Schema::$m();
         //$imageFields = explode(",", $parameters['imageFields']);
         foreach ($parameters as $key => $value) {
             if (!(strpos($key, 'attr') === false) && $key != "attrRewriteUrl") {
                 $key = str_replace('attr', '', $key);
                 if ($properties && $key != "Password" && !in_array($key, $properties)) {
                     continue;
                 }
                 if ($key == "Password" && empty($value)) {
                     continue;
                 }
                 $function = 'set' . $key;
                 if (is_array($value)) {
                     //$value = implode('-', $value);
                     $date = $value['year'] . '-' . $value['month'] . '-' . $value['day'];
                     // 2009-02-09 16:10:20
                     if ($value['hour'] && $value['minute']) {
                         $time = $value['hour'] . ':' . $value['minute'];
                         $value = $date . ' ' . $time;
                     } else {
                         $value = $date;
                     }
                 }
                 /*if (in_array($key, $imageFields))
                 					{
                 					$getFunction = 'get'.$key;
                 
                 					$imgId = $obj->$getFunction();
                 					if ($imgId != $value)
                 					{
                 					$img = Document::getDocumentInstance($imgId);
                 					if ($img)
                 					{
                 					$imgExt = $img->getExtention();
                 					@unlink(sfConfig::get('sf_root_dir')."/www/media/upload/thumbs/".$parameters["moduleName"]."/".$imgId."-".$key.".".$imgExt);
                 					}
                 					}
                 					}*/
                 if ($key == "Keywords") {
                     if ($value) {
                         $value = str_replace(',', '][', $value);
                         $value = '[' . substr($value, 0, -1);
                     }
                 }
                 $obj->{$function}($value);
             }
             /*if (in_array($key, $imageFields) && (!empty($value)))
             		{
             			$image = Document::getDocumentInstance($value);
             			if ($image)
             			{
             				if (empty($parameters[$key.'_thumbheight']))
             				{
             					$parameters[$key.'_thumbheight'] = null;
             				}
             				if (empty($parameters[$key.'_thumbwidth']))
             				{
             					$parameters[$key.'_thumbwidth'] = null;
             				}
             				$image->resizeImage($parameters["moduleName"], $parameters[$key.'_thumbheight'], $parameters[$key.'_thumbwidth'], $key);
             			}
             		}*/
         }
         if (class_exists($documentName . "I18n") && $documentName != "Listitem") {
             if (!($culture = $parameters["attrCulture"])) {
                 if (SF_APP == "panel") {
                     $culture = sfContext::getInstance()->getUser()->getCulture();
                 } else {
                     $culture = Document::getDocumentByExclusiveTag("default_culture");
                 }
                 if ($culture) {
                     $culture = $culture->getValue();
                 } else {
                     throw new Exception("No default culture defined");
                 }
             }
             $obj->save(null, $parent, $culture);
             if (!$parameters["id"] || SF_APP == 'panel') {
                 if (class_exists($documentName . "I18n")) {
                     if (SF_APP == "panel") {
                         $objI8n = Document::getDocumentByCulture($obj, null, true);
                     }
                     self::objectSave($objI8n, $obj, $documentName . "I18n");
                     if ($documentName == "Page") {
                         $objI8n->setRewriteUrl($parameters["attrRewriteUrl"]);
                     }
                     $objI8n->setCulture($culture);
                     $objI8n->save(null, $obj, $culture);
                 }
                 if (SF_APP != "panel") {
                     $request = sfContext::getInstance()->getRequest();
                     $request->setParameter("id", $obj->getId());
                 }
             }
         } else {
             $obj->save(null, $parent);
         }
         $tags = Document::getAvailableTagsOf($parameters['moduleName'], $documentName);
         foreach ($tags as $tag) {
             if ($parameters['tag_id_' . $tag->getId()]) {
                 Document::addTag($obj, $tag->getTagId());
             } else {
                 Document::removeTag($obj, $tag->getTagId());
             }
         }
         Tagrelation::updateTagRelationCache();
         UtilsHelper::setBackendMsg("Saved");
     } catch (Exception $e) {
         throw $e;
     }
     if (SF_APP == "panel") {
         self::panelRedirect();
     }
 }
예제 #21
0
파일: sfPakeImport.php 프로젝트: kotow/work
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);
}
예제 #22
0
파일: Media.php 프로젝트: kotow/work
 public function save($con = null, $parent = null, $refreshTree = true)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         $genericDoc = Document::getGenericDocument($this);
         if (!$this->getId()) {
             $this->setId($genericDoc->getId());
         }
         parent::save($con);
         // create relationship
         if (!$parent) {
             $parent = Document::getParentOf($this->getId(), null, true, false);
             if (empty($parent)) {
                 $parent = Rootfolder::getRootfolder($this);
             }
         }
         Relation::saveRelation($parent, $this);
         $con->commit();
         Document::cacheObj($this, "Media", $refreshTree);
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }